Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selection changed of datagrid does not changes the current row index

In my datagrid am changing the row selection based on some values.

 dgvGetData.Rows[rowIndex].Selected = true;

but in the Datagrids selection changed event the current row index is not changed to the rowIndex.it is still the same before i set dgvGetData.Rows[rowIndex].Selected = true;

like image 647
Sruthi Suresh Avatar asked Oct 21 '25 17:10

Sruthi Suresh


1 Answers

I found the answer I set the code as the following

rowIndex = row.Index;
                        dgvGetData.ClearSelection();


                        dgvGetData.CurrentCell = dgvGetData.Rows[rowIndex].Cells[2];
                        dgvGetData.CurrentRow.Selected = false;
                        dgvGetData.Rows[rowIndex].Selected = true;

when i added the lines

gvGetData.CurrentCell = dgvGetData.Rows[rowIndex].Cells[2];
                            dgvGetData.CurrentRow.Selected = false;

that worked and returned selected row index as current index..

like image 82
Sruthi Suresh Avatar answered Oct 23 '25 07:10

Sruthi Suresh