winforms - c# datagridview checkboxes matrix -
i trying make datagridview checkboxes matrix work in particular way. mandatory requirements are.
- only 1 checkbox in datagridview row can selected.
- one checkbox per row must selected.
program reading file during start , creating rows 3 out of 5 columns tick boxes column. make work in such way 1 tick box can selected per row , make impossible deselect tick box nothing in row selected.
currently make sure 1 tickbox per row selected using code:
private void datagridview1_cellcontentclick(object sender, datagridviewcelleventargs e) { (int = 0; <= 2; i++) { datagridview1.rows[e.rowindex].cells[i].value = false; } }
nevertheless see row 2-3 have nothing selected. how can prevent unchecking checked box leave ability check other box in row?
not sure want, may try this:
private void datagridview1_cellcontentclick(object sender, datagridviewcelleventargs e) { if (datagridview1.rows[e.rowindex].cells[e.cellindex].value == false) { (int = 0; <= 2; i++) { if (i != e.cellindex) datagridview1.rows[e.rowindex].cells[i].value = false; } } }
Comments
Post a Comment