943,800 Members | Top Members by Rank

Ad:
May 7th, 2009
0

Checking and UnChecking a CheckListBox

Expand Post »
Hi

I have a checklist box and I am trying to Check and Uncheck the the Items with a single click.
My code seams to be checking and uncheking if the Item is not selected.
If I Click on an Item that is checked it will uncheck it or vice versa, but if I click on that same Item to check it again it won't.
Here is the coed.

Private Sub chklstBuilder_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles chklstBuilder.Click
        Dim I As Integer = chklstBuilder.SelectedIndex()

        If (chklstBuilder.GetItemCheckState(I)) = CheckState.Checked Then
            chklstBuilder.SetItemCheckState(I, CheckState.Unchecked)
            Exit Sub
        End If

        If (chklstBuilder.GetItemCheckState(I)) = CheckState.Unchecked Then
            chklstBuilder.SetItemCheckState(I, CheckState.Checked)
        End If
    End Sub
thank you
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
VIPER5646 is offline Offline
83 posts
since Mar 2009
May 8th, 2009
0

Re: Checking and UnChecking a CheckListBox

Hi,

CheckListBox, Automatically Toggles between Check and UnCheck, you dont have to write the code in Click event. Remove all the Code and Check..

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
May 8th, 2009
0

Re: Checking and UnChecking a CheckListBox

yes it does but I have to double click and I want it to do it just with a single click.
can you help?
thanks
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
VIPER5646 is offline Offline
83 posts
since Mar 2009
May 9th, 2009
0

Re: Checking and UnChecking a CheckListBox

try posting in vb.net forum... this forum is for vb6..
Reputation Points: 19
Solved Threads: 115
Nearly a Posting Virtuoso
cguan_77 is offline Offline
1,317 posts
since Apr 2007
May 9th, 2009
0

Re: Checking and UnChecking a CheckListBox

Hi,

You can make it to Toggle with Single Click:
Write this in Form Load:

chkListBox1.CheckOnClick = True

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
May 9th, 2009
0

Re: Checking and UnChecking a CheckListBox

Thank you all for your help .
qveen72's works great.
Reputation Points: 10
Solved Threads: 2
Junior Poster in Training
VIPER5646 is offline Offline
83 posts
since Mar 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: VB6 - dll file not found error 53
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Password





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC