winforms - c# datagridview checkboxes matrix -


i trying make datagridview checkboxes matrix work in particular way. mandatory requirements are.

  1. only 1 checkbox in datagridview row can selected.
  2. 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?

enter image description here

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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -