Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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.

VB
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
Posted
Comments
Sergey Alexandrovich Kryukov 1-Jan-13 21:02pm    
If is System.Windows.Forms? Then tag: "Forms".
—SA
prashant patil 4987 1-Jan-13 23:27pm    
@Janna: try to clear your question first..

1 solution

How knows what you do? Anyway, not checking is any check box is checked or not.

Who known what is dgAllow.Item? It item's Value 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 write If 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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900