Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
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
Posted 1-Jan-13 15:29pm
Comments
Sergey Alexandrovich Kryukov at 1-Jan-13 21:02pm
   
If is System.Windows.Forms? Then tag: "Forms".
—SA
prashant patil 4987 at 1-Jan-13 23:27pm
   
@Janna: try to clear your question first..

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 304
1 Sergey Alexandrovich Kryukov 255
2 Maciej Los 250
3 Shweta N Mishra 216
4 PIEBALDconsult 174
0 OriginalGriff 7,660
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,586
3 Manas Bhardwaj 4,946
4 Maciej Los 4,665


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100