Click here to Skip to main content
11,637,176 members (68,485 online)
Rate this: bad
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
Posted 1-Jan-13 14:29pm
Sergey Alexandrovich Kryukov at 1-Jan-13 21:02pm
If is System.Windows.Forms? Then tag: "Forms".
prashant patil 4987 at 1-Jan-13 23:27pm
@Janna: try to clear your question first..

1 solution

Rate this: bad
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:[^].

Happy New Year!


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

  Print Answers RSS
0 stibee 313
1 295
2 OriginalGriff 295
3 himanshu agarwal 184
4 Sergey Alexandrovich Kryukov 154
0 OriginalGriff 9,031
1 Sergey Alexandrovich Kryukov 8,513
2 Mika Wendelius 6,922
3 F-ES Sitecore 2,388
4 Suvendu Shekhar Giri 2,320

Advertise | Privacy | Mobile
Web04 | 2.8.150728.1 | Last Updated 1 Jan 2013
Copyright © CodeProject, 1999-2015
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