c# - DataGridView and CheckBoxes -


i'm making application has page button , datagridview inside.

the data comes mysql , population done way:

this.objectstable.rows.add(objects.getvalue(index, 0),                             objects.getvalue(index, 1),                             objects.getvalue(index, 2),                             objects.getvalue(index, 3)); 

the problem:

i cannot check checkbox. literally. when click it goes "pressed/onpress" state never goes "checked".

how fix that? , how get row checkbox checked? want make array , iterate through them.

first check if datagridview either enabled or not readonly, if did not check if column not read only.

second part of question answer depends if want know checkbox has been checked or not. yes use event:

private void gridcellvaluechanged(object sender, datagridviewcelleventargs e) {     if (e.rowindex < 0 || e.columnindex < 0)     {         return;     }      if (datagridview1[e.columnindex, e.rowindex] datagridviewcheckboxcell)     {         var check = (datagridview1[e.columnindex, e.rowindex].value bool?) ?? false;          if (check)         {             //checked         }     } } 

or iterate through rows , check value of cell checkbox:

foreach (datagridviewrow row in datagridview1.rows) {       var check = (row.cells[0].value bool?) ?? false; } 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -