Click here to Skip to main content
12,627,681 members (33,557 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB 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
   
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

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
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161205.3 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2016
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