如何在有界DataGridView中启用无界DataGridViewCheckboxColumn的检查或取消选中? [英] How do you enable checking or unchecking of unbounded DataGridViewCheckboxColumn in bounded DataGridView?

查看:71
本文介绍了如何在有界DataGridView中启用无界DataGridViewCheckboxColumn的检查或取消选中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试弄清楚如何启用用户检查或取消选中无界DataGridViewCheckboxColumn。我有多个DataGridView对象。每个都绑定到他们自己的个人DataView对象。所有DataView对象的表都绑定到单个DataTable。每个DataGridView对象中都有三列,但是只有两列是从DataTable中检索的,我的复选框列是第三列无限制的。



我用Google搜索了类似的问题,但它对我不起作用。



DataGridView的属性Enabled和Readonly分别为true和false。 DataGridViewCheckboxColumn的属性Readonly为false。 DataView的属性AllowEdit也设置为true。我还缺少什么或需要设置以启用用户检查或取消选中?

Hi, I am trying to figure out how to enable user checking or unchecking of an unbounded DataGridViewCheckboxColumn. I have multiple DataGridView objects. Each of which is bounded to their own individual DataView object. The table of all DataView objects is tied to a single DataTable. There are three columns in each of my DataGridView objects, but only two of them is retrieved from the DataTable with my checkbox column being the third unbounded one.

I Googled for similar problems, but it isn't working for me.

Property Enabled and Readonly for DataGridView are true and false, respectively. Property Readonly for DataGridViewCheckboxColumn is false. Property AllowEdit for DataView is set to true as well. What else am I missing or need to set to enable user checking or unchecking?

推荐答案

我发现了问题。这是我的MouseDown事件有问题,因为在处理程序中,我将其编程为执行DoDragDrop()。由于DoDragDrop()正在进行中,因此完全忽略了复选框的选中或取消选中。



为了解决我的问题,我必须使用Timer并添加MouseUp事件处理程序,用于区分何时选中或取消选中该框以及何时拖放。尽管它使用我当前的源代码并不像我想要的那样完美,但至少可行。现在,解决我的其他问题...



哦,谢谢那些试图帮助我的人。
I found the problem to my issue. It was my MouseDown event at fault, because in the handler, I programmed it to perform a DoDragDrop(). Since DoDragDrop() is in process, the checking or unchecking of the checkbox is completely ignored.

In order to fix my issue, I have to use a Timer and add a MouseUp event handler to differentiate when to check or uncheck the box and when to drag and drop. Even though it isn't working as perfectly as I wanted with my current source code, it at least works. Now, onto my other problems...

Oh, thanks for those who tried to help me out.


这篇关于如何在有界DataGridView中启用无界DataGridViewCheckboxColumn的检查或取消选中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆