hi guys, I have a datagridview in which i have fourth column as checkbox.On clicking checkbox i want to get checkbox value in codebehind.Can anybody help?
A:
You should not try to access the CheckBox.Checked value directly, rather get the value from whatever it is bound to.
If you really want to get it from the checkbox you can do something like myDataGridView.Rows[0].Cells[3].Value
David
2010-01-07 14:48:26
A:
You can also subscribe to the "EditingControlShowing" event of the dgv. When this event is triggered you can get the control that is showing (which is a checkbox), cast it into a checkbox and subscribe to the "CheckedChanged" event.
Also, remember to subscribe to the "CellEndEdit" of the dgv to add a call to unsubscribe to the "CheckedChanged" after the edit of the checkbox, otherwise after you change from a cell to an other, you will receive events from others cells.
Pierre-Luc Champigny
2010-01-07 15:17:45