DataGridView Checkbox

  • Thread starter Thread starter Carolina
  • Start date Start date
C

Carolina

Hello,

Is there any way I could get an event like a CheckboxChanged for a checkbox
in the datagridview?

I tried to do this with the event CellContentClick but it happens just
before the value of the checkbox changes.

Thanks in advance,
 
Hello,

Is there any way I could get an event like a CheckboxChanged for a checkbox
in the datagridview?

I tried to do this with the event CellContentClick but it happens just
before the value of the checkbox changes.

Thanks in advance,

Gday Carolina,

I am having issues of my own with datagridviews and checkboxes at
present...

I dont know your situation and whether or not you actually do need to
capture the checkedchanged event when it actually happens...

What I do is have the checkboxes as unbound, and when the form loads
up or there is a datarefresh I will set the checkboxes based off the
appropriate values in my data. And when a save operation takes place
do the reverse - check the values of each checkbox and set the
appropriate value in the data to be saved out.

I dont know if this helps.

Let me know if you get any responses about your original question.

Thanks!

Peter
 
Ey!!

Thanks Peter for your attention.

Well, It's been quite complicated this. What I actually need is everytime I
check on the checkbox, to do a validation (comparing the value of a column
between rows selected), and after that if the validation is correct then
leave the checkbox checked. If the validation is incorrect then uncheck the
checkbox.

I tried with the event CurrentCellDirtyStateChange, doing the commit of the
edition here everytime IsCurrentCellDirty is in false. But its being still
difficult getting back to the previous state, when the checkbox were
unchecked.

I even tried this code which is supposed to capture SelectedIndexChanged for
a combobox. Well I thought it would work if i adapted it to a CheckBox:
private void dataGridView1_EditingControlShowing(object sender,

DataGridViewEditingControlShowingEventArgs e)

{

CheckBox cb = e.Control as CheckBox;

if (cb != null)

{

cb.CheckedChanged-= new
EventHandler(cb_CheckedChanged);



cb.CheckedChanged+= new
EventHandler(cb_CheckedChanged);

}

}



void cb_CheckedChanged(object sender, EventArgs e)

{

MessageBox.Show("Selected index changed");
}



But nop, it didnt work well.



I don't really know what to do.





Thanks again,



Carolina
 
Back
Top