Hi,
I am trying to set the selected row based on the value.
Here's the code
string id; for (int i = 0; i < grdscreens.Rows.Count; i++) { id = grdscreens.Rows[i].Cells[1].Text; if (id == _screenID) { grdscreens.Selected.Rows[i].Selected = true; } }
MainForm has a grid and user doubleclicks on one of the records and i take the selected value from that Grid and open a new form with the value passed to the child form. But the Child form retrieves all the records on startup and i need to set the selection to the value that was passed in to make it look like thats the row the user double clicked on so user can start editing that record.
But it looks like i get a exception when it hits the grdscreens.selected.rows[i].selected = true;
please let me know how i can make it work.
Thanks
I think i fixed the problem.
string id; for (int i = 0; i < grdscreens.Rows.Count; i++) { id = grdscreens.Rows[i].Cells[1].Text; if (id == _screenID) { grdscreens.Rows[i].Selected = true; } }
the problem was the grdscreens.Selected.Rows[i].Selected = true;
Since there is no Selected Rows i need to set that to grdscreens.rows[i].Selected