Datagridview transfer selected rows - vb.net

How can I transfer selected rows from datagridview to another datagridview in another form? I'm having trouble with this.

You should be able to do that in in one of gridview event handlers. I would use
RowCommand Occurs when a button is clicked in a GridView control.
But you can do it any other event that meets your needs. Both the Gridview must be on same page so you can access them from code behind. You can access any control on the page using code behind, including GridView. You should be able to add contents/remove contents as needed. Make sure you issue databaind on both gridviews so they are rendered fresh after the changes. So basically you need code behind :)

Related

GridView RowDataBound event makes my GridView slow

I have a PopupExtender that shows some information when a button in the GridView is pressed. This button exists on every row.
I also have a DropDownList present in every row that is populated by querying a database. I do this because it may be populated with different items depending on the row.
The problem I have is that the PopupExtender is slow to pop-up because of the RowDataBound event of the GridView that repopulates the DDLs from the database when the PopupExtender's associated button is pressed.
How can I make the PopUpExtender pop-up faster?
You may need to consider jQuery Dialog instead of Asp.Net ajax popup extender.
http://jqueryui.com/dialog/.
Also, do you really need gridview, You can try ListView control instead of GridView.

Is there an event which fires before a user enters a row into the datagridview in .net 3.5

I am trying to create a wrapper to replace the sheridan datagrid actvex control with a datagridview.
The sheridan datagrid control supports an event which fires just before the user is going to add a row to the grid called BeforeInsert.
Does anyone know of an equivalent event in the datagridview control or or some other code I could write which produces the same effect?
I'm having a look at all the events here, I don't see one for Adding or Inserting a row, just Added. Although there's one for Deleting and Deleted strangely enough. I won't pretend to know why. To your question, how exactly will users be adding rows? You could try playing around with the "AllowUserToAddRowsChanged" event and change that property programatically when the user wants to add a row.

Silverlight 4: DataForm, currentItem and AutoCommit

I have a DataGrid and a DataForm. I'm assigning data to the DataForm with the currently selected Item in the datagrid individually as DataForm.CurrentItem. This means that I do not have any Next/Previous button on the DataForm and the user can switch to any row in the DataGrid.
My problem is that although I have set the property AutoCommit="True" on the DataForm, if the user edits something and clicks on another record in the DataGrid, it crashes.
How can I force it to save the DataForm when the user moves away from the form?
I got this working but I'm not sure whether this is correct. On SelectionChanged event of datagrid I added the following:
DataForm.CommitEdit();
and it stopped crashing and giving me the error. If anyone else has a better solution please do let me know.

Hiding columns in a datasheet

I am trying to hide specific columns in an Access 2007 split form through code. I need the form to check certain conditions to see whether it needs to display a column or not. I have code in the form's 'Activate' event to hide the column like this:
txtControl.ColumnHidden = True
This code works in the "Open" event, but if I hide the column on Activate, it won't display these changes until I close the form and open it again. I have tried calling the form's refresh, repaint, and requery methods, but this doesn't work. Please help!
Edit: Ideally, I need this event to occur whenever the focus switches to this form.That's why I'm using the Activate event rather than the Open event.
Try setting it in either the form's Current or Load events. You will also probably need to requery the control after setting that property: Me.TextControl.Requery Current is called every time a form's record is changed, the form is repainted or requeried. Load, as its name suggests, is called once, after the form has opened when the form loads its records. These have always been more reliable for me than using Activate, which really has to do with more the focus of the form, not really what you want.
I've had a problem like this before working in Access 2002. I was able to solve the problem with a subform by setting the subform source object equal to itself and then running the requery.
Me.SubForm.SourceObject = Me.SubForm.SourceObject
Me.SubForm.Requery
See if this technique works for your particular situation.

Informing the user that a DataGridView is being populated

I am writing a program in VB.Net to manage text messages sent through an API. It allows you to view messages in a datagridview and filter by date, sent/unsent etc...
To load the messages I'm executing an SQL statement and retrieving a DataTable which then gets set as the DataSource for my DataGridView control.
The problem is that depending on the filters selected the user could be selecting a lot of records and it would take some time for the DataSource to update. I want to inform the user of this load time by providing a progress bar or label of some kind.
I have used progress bars before when looping through data but this is loading it all at once. I thought of displaying a label when the user clicks to load the data and then hiding it when the data is loaded. But this happens instantaneously even when the data is still loading.
Is there an event on the DataGridView I can use perhaps? Something like .DataSourceLoadStart and .DataSourceLoadFinished.
I know I'm just making those events up... but hopefully it makes it clearer as to what I want.
You could set the label to be visible when load is clicked and try the: DataGridView.DataBindingComplete Event to hide it, this event gets called when the binding is complete.
MSDN Link - DataBindingComplete
A little off topic but... I wonder if you could attach a AJAX update panel with activity/loading image to a gridview? I don't think I've ever seen it done but here's a great application for it.