How to maintain scroll position in DataGridView after updating and refilling datagrid
Hello,
I was wondering if there is a way to keep the scroll position in a datagridview on a windows application after updating a record and refreshing the datagridview.
i am working with vb.net 2005. i have some textboxes where I load the corresponding fields from the datagridview. then the user is able to update the fields in the textboxes and then click on the update button whrere an update storeprocedure is executed and the I refill the datagridview to reflect the changes made. but I want to be able to maintain the scroll position in the same position and not going all the way to the top as it is doing rightnow.
This is how i am Re-Filling my datagridview:
Me.ClientsTableAdapter.Fill(Me.ACHReaderDataSetTblClients.Clients)
thanks for any suggestion, or example.
Re: How to maintain scroll position in DataGridView after updating and refilling datagrid
That is extremely wasteful. There's no need for you to be getting all your data again. All you need to do is assign the new data to the row of your DataTable and call AcceptChanges. All the other data is untouched so there's no need to throw it all away only to retrieve it again.
Having said that, you normally wouldn't be saving one row at a time either. You'd normally let the user make all the changes first and then save them as a batch.
Re: How to maintain scroll position in DataGridView after updating and refilling datagrid
Hello thanks for your suggestion, please let me know how to assign the new data to the row of the DataTable and call AcceptChanges. Can you provide an example.
Thanks,