Click here to Skip to main content
16,021,288 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a data entry form with local database.sdf and a datagridview, when I select a row and update it, how do I keep focus on the selected row after update instead of it going to the first row again
Posted

1 solution

Solution for Windows Form:
You can use DataGridView.CurrentCell[^] property.

Example:
C#
DataGridViewCell cell = this.dataGridView1.Rows[RowIndex].Cells[ColumnIndex];
//update
this.dataGridView1.CurrentCell = cell;
 
Share this answer
 
Comments
r5five 9-Mar-13 2:12am    
but how do I declare the code for the current selected row. using the above code I can set the current cell to a specified row and cell but how to set it automatically to a selected row
Maciej Los 9-Mar-13 12:38pm    
Just try it. CurrentRow property is read only. CurrentCell is what you're looking for ;)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900