c# - DataGridViewRow Wrong Cell Index -
i've got problem while trying values through datagridviewrow. problem cell index 7 , when try data cell using code:
foreach (datagridviewrow r in this.mydatagrid.rows) { if (convert.toboolean(r.cells[0].value) == true) { datagridviewcomboboxcell cc = (datagridviewcomboboxcell)r.cells[7]; cc.value = toolstripcombobox1.selecteditem.tostring(); edit_subject(convert.toint32(r.cells[1].value), r.cells[7].value.tostring()); }
an exception error comes saying cells[7] outofindex . i've tried change cell index 7 5 , it's worked , , no .
please need explain because it's weird.
ok found solution, problem caused because sql syntax (the datagrid datasource) has different order datagridview columns, didn't because datagrid autofill has been disabled . , i've set datapropertyname each column manually.
anyway , response.
Comments
Post a Comment