Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Actually I will have a form open when I click on a row of the datagridview. After making the necessary changes and clicking on save I would like to select that particular row as selected which I previously had selected.

Thank you!
Posted
Updated 2-Dec-10 23:13pm
v2
Comments
Manfred Rudolf Bihy 3-Dec-10 5:14am    
Minor edits for spelling and grammar.

1 solution

U need to keep index of selected row before opening form to edit, and after make changes again set selected row as index taken before opening editor page.

.......
CurrentIndex=datagridview1.selectedrows[0].index;
frmEdiotor.showDialog()
datagridview1.clearselection();
datagridview1.rows[CurrentIndex].seclected=true;
....
 
Share this answer
 
Comments
demouser743 4-Dec-10 0:15am    
Hi a small change

int currRow = 0;
currRow = dataGridView1.CurrentRow.Index;

dataGridView1.ClearSelection();
dataGridView1.Rows[currRow].Selected = true;

This gives the solution

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