Checking and UnChecking a CheckListBox

Thread Solved

Join Date: Mar 2009
Posts: 40
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

Checking and UnChecking a CheckListBox

 
0
  #1
May 7th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Checking and UnChecking a CheckListBox

 
0
  #2
May 8th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 40
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

Re: Checking and UnChecking a CheckListBox

 
0
  #3
May 8th, 2009
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 1,102
Reputation: cguan_77 has a little shameless behaviour in the past 
Solved Threads: 91
cguan_77's Avatar
cguan_77 cguan_77 is offline Offline
Veteran Poster

Re: Checking and UnChecking a CheckListBox

 
0
  #4
May 9th, 2009
try posting in vb.net forum... this forum is for vb6..
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Checking and UnChecking a CheckListBox

 
0
  #5
May 9th, 2009
Hi,

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

chkListBox1.CheckOnClick = True

Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Mar 2009
Posts: 40
Reputation: VIPER5646 is an unknown quantity at this point 
Solved Threads: 0
VIPER5646's Avatar
VIPER5646 VIPER5646 is offline Offline
Light Poster

Re: Checking and UnChecking a CheckListBox

 
0
  #6
May 9th, 2009
Thank you all for your help .
qveen72's works great.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC