problem with check boxes and listboxes

Please support our VB.NET advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Jul 2007
Posts: 58
Reputation: bpacheco1227 is an unknown quantity at this point 
Solved Threads: 0
bpacheco1227 bpacheco1227 is offline Offline
Junior Poster in Training

problem with check boxes and listboxes

 
0
  #1
Sep 16th, 2008
Upon checking the corresponding check box, which is either Ladies Shoes, Men Shoes, Sneakers or Sandals, the program needs fill the listbox with the checkbox information. Can't figure the syntax, any help would be greatly appreciated.

  1. Public Class Form1
  2.  
  3. Private Sub chkboxLadiesShoes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkboxLadiesShoes.CheckedChanged
  4. Dim ladiesShoes As String = "Ladies Shoes"
  5.  
  6. If chkboxLadiesShoes.CheckState = 1 Then
  7. lstDisplay.Text = ladiesShoes
  8. ElseIf chkboxLadiesShoes.CheckState = 2 Then
  9. lstDisplay.Items.Clear()
  10.  
  11. End If
  12. End Sub
  13.  
  14. Private Sub chkboxMenShoes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkboxMenShoes.CheckedChanged
  15. Dim menShoes As String = "Men Shoes"
  16. If chkboxMenShoes.CheckState = 1 Then
  17. lstDisplay.Text = menShoes
  18. ElseIf chkboxMenShoes.CheckState = 2 Then
  19. lstDisplay.Items.Clear()
  20.  
  21. End If
  22. End Sub
  23. Private Sub chkSneakers_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkboxSneakers.CheckedChanged
  24. Dim sneakers As String = "Sneakers"
  25. If chkboxSneakers.CheckState = 1 Then
  26. lstDisplay.Text = sneakers
  27. ElseIf chkboxSneakers.CheckState = 2 Then
  28. lstDisplay.Items.Clear()
  29.  
  30. End If
  31. End Sub
  32.  
  33. Private Sub chkSandals_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkboxSandals.CheckedChanged
  34. Dim Sandals As String = "Sandals"
  35. If chkboxSandals.CheckState = 1 Then
  36. lstDisplay.Text = Sandals
  37. ElseIf chkboxSandals.CheckState = 2 Then
  38. lstDisplay.Items.Clear()
  39.  
  40. End If
  41. End Sub
  42.  
  43.  
  44. Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
  45. Me.Close()
  46. End Sub
  47. End Class
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: problem with check boxes and listboxes

 
0
  #2
Sep 17th, 2008
Not clear...you want to add item into list when user checked it?
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 58
Reputation: bpacheco1227 is an unknown quantity at this point 
Solved Threads: 0
bpacheco1227 bpacheco1227 is offline Offline
Junior Poster in Training

Re: problem with check boxes and listboxes

 
0
  #3
Sep 17th, 2008
yes
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: problem with check boxes and listboxes

 
0
  #4
Sep 17th, 2008
so this line is wrong "lstDisplay.Text"
change with
lstDisplay.Items.Add(CurrentItem)
ex: lstDisplay.Items.Add(ladiesShoes)
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 58
Reputation: bpacheco1227 is an unknown quantity at this point 
Solved Threads: 0
bpacheco1227 bpacheco1227 is offline Offline
Junior Poster in Training

Re: problem with check boxes and listboxes

 
0
  #5
Sep 17th, 2008
Thanks, that did it, there's only one more thing. When user unchecks each box the list box should clear, which should be lstDisplay.Items.Clear() which of course does not work, could it be my IF statements? Any insight?
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: problem with check boxes and listboxes

 
2
  #6
Sep 17th, 2008
Actually i didn't agree with your if statement :
If you want to know check box is checked or not then use Checked function :
Try this :
Private Sub chkboxLadiesShoes_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles chkboxLadiesShoes.CheckedChanged
        Dim ladiesShoes As String = "Ladies Shoes"

        If chkboxLadiesShoes.Checked = True Then
            lstDisplay.Items.Add(ladiesShoes)
        ElseIf chkboxLadiesShoes.Checked = False Then
            lstDisplay.Items.Clear()
        End If
End Sub
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 58
Reputation: bpacheco1227 is an unknown quantity at this point 
Solved Threads: 0
bpacheco1227 bpacheco1227 is offline Offline
Junior Poster in Training

Re: problem with check boxes and listboxes

 
0
  #7
Sep 17th, 2008
great, thank you, works perfectly. Just shows how important syntax is. Thanks Again.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2,641
Reputation: Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light Jx_Man is a glorious beacon of light 
Solved Threads: 245
Jx_Man's Avatar
Jx_Man Jx_Man is offline Offline
Posting Maven

Re: problem with check boxes and listboxes

 
0
  #8
Sep 17th, 2008
you're welcome
Never tried = Never Know
So, Please do something before post your thread.
* PM Asking will be ignored *
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 VB.NET Forum
Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC