简体   繁体   English

如何在 DataGridView 中捕获 CheckBox 更改事件?

[英]How to catch CheckBox changed event in the DataGridView?

I am changing the value of a cell of type DataGridViewCheckBoxColumn (check and uncheck a CheckBox) in the DataGridView control.我正在更改 DataGridView 控件中 DataGridViewCheckBoxColumn 类型的单元格的值(选中和取消选中 CheckBox)。 Is there any way to catch this event?有什么办法可以捕捉到这个事件吗? CellEndEdit event fires only if I select another cell.仅当我 select 另一个单元格时才会触发 CellEndEdit 事件。

I hope you can check try CellValueChanged event, but hooking an event doesn't seems to be possible and as you would have observed it happens as soon as you move out of the cell.我希望您可以检查尝试CellValueChanged事件,但挂钩事件似乎是不可能的,正如您所观察到的那样,一旦您移出单元格,它就会发生。 This tells the Grid that Editing is complete for the cell.这告诉网格单元格的编辑已完成。

I vaguely remember doing something like in the mouseup event for the cell make sure to do DataDrigView1.EndEdit() and this should help you rollout your logic in the CellValueChanged event by checking the checked state.我隐约记得在单元格的 mouseup 事件中执行类似操作,确保执行DataDrigView1.EndEdit() ,这应该有助于您通过检查选中的 state 在 CellValueChanged 事件中推出逻辑。 (Sorry cannot test it as of now) (抱歉目前无法测试)

Or maybe this might work 或者也许这可能有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM