The grid's current row can be changed using the grid's CurrentRow property or the MoveCurrentRow method. Any visible row, not just DataRows, can be the current row.
Keep in mind that the current row might or might not be part of the grid's SelectedRows. If you want to the current row to be selected, you will need to add it to the grid's collection of selected rows.
Only rows whose CanBeCurrent property is set to true can be current.
If the row is in a collapsed group or its Visible property is set to false, and exception will be thrown.
The following examples demonstrate how to make various rows current:
VB.NET | Copy Code |
---|---|
|
C# | Copy Code |
---|---|
|
When setting the CurrentRow property or calling the MoveCurrentRow method, the BringIntoView method must be called if you want to bring the new current row into view.