c# - Cannot set row to be selected -
i have 1 strange problem , don't have clue how solve it. here is: have 2 forms. first form take row (with index), , data row display in form possibility edit data. time have index of row datagridview in first form. when edit data in second form , press update button, want data applied in same row in first form. here code further info:
if (datagridview.selectedrows.count == 0) { messagebox.show("index of row must selected " + rowindex); datagridview.rows[rowindex].selected = true; }
now, when form2 closed want check if still have same row selected in first form, , if not, select it. on line .selected = true; error: index out of range. must non-negative , less size of collection.
messagebox above line gives me right index of row... example, datgridview have 100 rows , work row index 5. why don't understand why error "index out of range"... why can't select row again?
Comments
Post a Comment