Combo Box Help

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

Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Combo Box Help

 
0
  #1
Feb 24th, 2009
Hi,
i wanted to link options selected from Comb box A (general) to specific options in combo box B (specific). I want to pick a word in Combo box A that has specific words/phrases in Combo Box B show. But not all the words to show in the combo box B if they aren't associated with the Word picked in Combo Box A. Ex.When "Soda" is picked in A, only "Coke, Sprite, Fanta" should be visible in combo box b, not everything else.

This is the code i used to make the boxes, but i don't know how to link them.

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' fills the combo boxes with values

Me.xGeneralComboBox.Items.Add("Soda")
Me.xGeneralComboBox.Items.Add("Juice")

Me.xxSpecificComboBox.Items.Add("Coke")
Me.xxSpecificComboBox.Items.Add("Sprite")
Me.xxSpecificComboBox.Items.Add("Fanta")

Me.xxSpecificComboBox.Items.Add("Apple")
Me.xxSpecificComboBox.Items.Add("Grape")
Me.xxSpecificComboBox.Items.Add("Pear")
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 29
Reputation: jbrock31 is an unknown quantity at this point 
Solved Threads: 1
jbrock31 jbrock31 is offline Offline
Light Poster

Re: Combo Box Help

 
0
  #2
Feb 24th, 2009
Couldn't you use:

Pseudocode:

if generalcomobobox is soda then
comboboxspecific items = sprite, etc.
elseif generalcombobox is Juice then
comboboxspecific items = apple, etc.


you could do this in generalcombo box's SelectedIndexChangedEvent.

Hope this helps. Not sure if this is what you need or not. Sorry if off base.
Last edited by jbrock31; Feb 24th, 2009 at 8:29 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Combo Box Help

 
0
  #3
Feb 24th, 2009
It really didn't do anything..thanks anyways
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 29
Reputation: jbrock31 is an unknown quantity at this point 
Solved Threads: 1
jbrock31 jbrock31 is offline Offline
Light Poster

Re: Combo Box Help

 
0
  #4
Feb 24th, 2009
What did you try? I didnt give any exact code as im sure you know. Show us some code. If i can't help, i'm sure another will.
Last edited by jbrock31; Feb 24th, 2009 at 9:39 pm.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Combo Box Help

 
0
  #5
Feb 24th, 2009
so far i tried this and i got it to show "coke" in SpecificComboBox when i selected "soda" in GeneralComboBox...

Private Sub xGeneralComboBox_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles xGeneralComboBox.SelectedIndexChanged

If xGeneralComboBox.Text = "Soda" Then
xSpecificComboBox.Text = "Coke"

End If

However, it i want the dropdown list to also show the other soda specific items only, not just one..if i add more stuff like
xSpecificComboBox.Text = "Sprite"
xSpecificComboBox.Text = "Fanta"

to continue the code below the "coke" but above the "end if" the sprite and fanta don't show.

I've done so many statements, with different combinations now every sees to look the same....
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 29
Reputation: jbrock31 is an unknown quantity at this point 
Solved Threads: 1
jbrock31 jbrock31 is offline Offline
Light Poster

Re: Combo Box Help

 
0
  #6
Feb 24th, 2009
I just create something in like 5 mins. This works for me. At form load i set enabled property of specific combo to false.

In the SelectedIndexChanged event for general combo box i enable the specific box and add the items based on the selected index. this is very basic and could be changed around if you needed it to be more sophisticated, but i was giving you a basic idea of how you could do what you were wanting.

  1. Private Sub cmbGeneral_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbGeneral.SelectedIndexChanged
  2.  
  3. cmbSpecific.Enabled = True
  4. cmbSpecific.Items.Clear()
  5.  
  6. If cmbGeneral.SelectedIndex = 0 Then
  7. cmbSpecific.Items.Add("Sprite")
  8. cmbSpecific.Items.Add("Dr. Pepper")
  9. ElseIf cmbGeneral.SelectedIndex = 1 Then
  10. cmbSpecific.Items.Add("Apple Juice")
  11. cmbSpecific.Items.Add("Orange Juice")
  12. End If
  13. End Sub
  14.  
  15. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  16.  
  17. cmbSpecific.Enabled = False
  18.  
  19. End Sub
  20. End Class
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Combo Box Help

 
0
  #7
Feb 26th, 2009
Ohhhhhhhhhhhhhhhhhhhhh I feel so dumb!!! I tried it and it worked...exactly what i was looking to do...i was stuck using this code:

If
Me.xGeneralComboBox.textselected =="Soda" then

Me.xSpecificComboBox.format("Sprite", "Fanta")

then i tried inheritance and i couldn't understand what i was doing...Thanks Alot!!!
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 19
Reputation: bondgirl21 is an unknown quantity at this point 
Solved Threads: 0
bondgirl21 bondgirl21 is offline Offline
Newbie Poster

Re: Combo Box Help

 
0
  #8
Feb 26th, 2009
I figured it out now, thanks everyone...

I used the Case Select method and i was able to add more things in A that B could Use (hopefully u get what am saying)
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 29
Reputation: jbrock31 is an unknown quantity at this point 
Solved Threads: 1
jbrock31 jbrock31 is offline Offline
Light Poster

Re: Combo Box Help

 
0
  #9
Feb 26th, 2009
Awesome. Glad you got it figured out. Good luck.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



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

©2003 - 2009 DaniWeb® LLC