954,559 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Checking and UnChecking a CheckListBox

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

VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
 

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

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

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

VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
 

try posting in vb.net forum... this forum is for vb6..

cguan_77
Nearly a Posting Virtuoso
1,317 posts since Apr 2007
Reputation Points: 19
Solved Threads: 115
 

Hi,

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

chkListBox1.CheckOnClick = True

Regards
Veena

QVeen72
Posting Shark
950 posts since Nov 2006
Reputation Points: 84
Solved Threads: 143
 

Thank you all for your help .
qveen72's works great.

VIPER5646
Junior Poster in Training
84 posts since Mar 2009
Reputation Points: 10
Solved Threads: 2
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You