Vb.net datagridview复选框 [英] Vb.net datagridview checkbox
本文介绍了Vb.net datagridview复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我需要帮助。有人可以帮帮我吗?
我真的想知道为什么我的代码总是返回false,即使选中了datagrid复选框。也许你可以帮帮我?谢谢!!
这是我的代码。
Dim hasItem As Boolean
对于 iCnt = 0 dgAllow.RowCount - 1
如果 dgAllow.Item( 1 ,iCnt)。值= True 然后
hasItem = True
退出 对于
结束 如果
下一步
解决方案
怎么知道你做了什么?无论如何,不检查是否勾选任何复选框。
谁知道什么是dgAllow.Item
?它的项目'$值是布尔值,检查看起来......好吧,很奇怪,因为你不需要将任何布尔值与true进行比较,因为它已经是布尔值,你应该写 如果dgAllow.Item(1,iCnt).Value那么
...
而且,这是巧合的是,一个复选框,这是测试它是否被检查的真正方法:
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.togglebutton.ischecked.aspx [< a href =http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.togglebutton.ischecked.aspxtarget =_ blanktitle =New Window> ^ ]。
新年快乐!
-SA
Hi All,
I need help. Can somebody help me please?
I''m really wondering why my code always return false even though the datagrid checkbox is checked. Maybe you can help me? Thanks!!
Here''s my code.
Dim hasItem As Boolean
For iCnt = 0 To dgAllow.RowCount - 1
If dgAllow.Item(1, iCnt).Value = True Then
hasItem = True
Exit For
End If
Next
解决方案
How knows what you do? Anyway, not checking is any check box is checked or not.
Who known what isdgAllow.Item
? It item''sValue
is Boolean, the check looks… well, strange, because you don''t need to compare any Boolean with true, as it is already Boolean, you should writeIf dgAllow.Item(1, iCnt).Value Then
…
And, it this is, by a coincidence, a check box, this is the real way to test if it is checked:
http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.togglebutton.ischecked.aspx[^].
Happy New Year!
—SA
这篇关于Vb.net datagridview复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文