Retrieving last row in databound DataGridView?

BlakeMcKenna

Active member
Joined
Oct 27, 2008
Messages
38
Programming Experience
10+
I have a DataGridView that is bound to a dataset. What I wish to do is when the grid is loaded...I want the last row to be the selected row. I also need to declare an instance of the row but not sure how to reference the last row.

This is what I have currently.

VB.NET:
Expand Collapse Copy
         Dim row As DataGridViewRow = grdStatus.CurrentRow

I need to have something like this:

VB.NET:
Expand Collapse Copy
         Dim row As DataGridViewRow = grdStatus.LastRow

Thanks,
 
The index of the last row in your datagridview is 1 less than the count

VB.NET:
Expand Collapse Copy
Me.grdStatus.Rows.Count - 1
 
Back
Top