I have a winforms app and want to trigger some code when a checkbox embedded in a DataGridView
control is checked / unchecked. Every event I have tried either
- Triggers as soon as the
CheckBox
is clicked but before its checked state changes, or - Triggers only once the
CheckBox
looses its focus
I can't seem to find event that triggers immediately after the checked state changes.
Edit:
What I am trying to achieve is that when the checked state of a CheckBox
in one DataGridView
changes, the data in two other DataGridView
s changes. Yet all the events I have used, the data in the other grids only changes after the CheckBox
in the first DataGridView
looses focus.
Best Answer
To handle the
DatGridView
sCheckedChanged
event you must first get theCellContentClick
to fire (which does not have theCheckBox
es current state!) then callCommitEdit
. This will in turn fire theCellValueChanged
event which you can use to do your work. This is an oversight by Microsoft. Do some thing like the following...I hope this helps.
P.S. Check this article https://msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.currentcelldirtystatechanged(v=vs.110).aspx