| | |
Combo Box Help
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2009
Posts: 19
Reputation:
Solved Threads: 0
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")
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")
•
•
Join Date: Oct 2008
Posts: 29
Reputation:
Solved Threads: 1
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.
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.
•
•
Join Date: Feb 2009
Posts: 19
Reputation:
Solved Threads: 0
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....
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....
•
•
Join Date: Oct 2008
Posts: 29
Reputation:
Solved Threads: 1
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.
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.
vb Syntax (Toggle Plain Text)
Private Sub cmbGeneral_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbGeneral.SelectedIndexChanged cmbSpecific.Enabled = True cmbSpecific.Items.Clear() If cmbGeneral.SelectedIndex = 0 Then cmbSpecific.Items.Add("Sprite") cmbSpecific.Items.Add("Dr. Pepper") ElseIf cmbGeneral.SelectedIndex = 1 Then cmbSpecific.Items.Add("Apple Juice") cmbSpecific.Items.Add("Orange Juice") End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load cmbSpecific.Enabled = False End Sub End Class
•
•
Join Date: Feb 2009
Posts: 19
Reputation:
Solved Threads: 0
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!!!
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!!!
![]() |
Similar Threads
- combo box (PHP)
- Want to use radio button or menu bar instead of combo box (Java)
- combo box (ASP)
- How do I limit text char in Combo box? (VB.NET)
- combo box help (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: How to Change Cell Backcolor if Datagridview2.item.value = Datagridview1.item.value
- Next Thread: DEADLOCK
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2008 access add arithmetic array assignment basic binary bing box button buttons c# center code combobox component connectionstring convert cpu data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dosconsolevb.net editvb.net excel file-dialog firewall folder google hardcopy image images isnumericfuntioncall listview login math memory mobile ms mssqlbackend mysql navigate net networking opacity output pan peertopeervideostreaming picturebox picturebox1 plugin port print printpreview problemwithinstallation project record reports" reuse save savedialog serial server sorting sql storedprocedure string temp text textbox timer toolbox updown upload useraccounts usercontrol vb vb.net vb.netcode vb.nettoolboxvisualbasic2008sidebar vbnet view vista visual visualbasic visualbasic.net visualstudio web wpf





