3
votes

Alright I have a DataGridView, where the user can click on the column headers to sort. When they add a new row while a sort is applied, the record isn't created until the moment they validate the row(which they cannot do till they exit the newRow). How can I make the row be selected once it is sorted?

The DataGridView is databound.

The selection mode for the grid is full row.

I'm using VB.NET with SQLite database backend.

I suspect I need to use the RowsAdded event, or DataBindingComplete events. The records in question do have a unique GUID attached but it is NOT visible in the DataGridView.

This c# question seems sort of along the lines of what I want: Select newly added Row - DataGridView and BindingSource. However the question is how do I make it fire the row validate (and thus the binding to DB) without leaving the row.

Screenshot

1

1 Answers

0
votes

Store the primary key (id) of the added record into a new field(insert command returns that), and loop through the gridview rows and select the row with the primary key. :)