LuckyLucks
asked on
displaying the selected text choice in a combobox
Hi,
This is an ez one and I dont know why I cant get it right. I am looking to display the selected text from drop down choices in a combobox.How do I do this? Please note I am not using associated values.
Thanks
This is an ez one and I dont know why I cant get it right. I am looking to display the selected text from drop down choices in a combobox.How do I do this? Please note I am not using associated values.
Thanks
ASKER
Not to display in a label's text but in the combo box itself. And this is after the selection is done i,e I select the item and after a while I want to reset the display portion of the combobox to say "apple"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi LuckyLucks,
Private Sub ComboBox1_SelectedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexCha nged
ComboBox2.Items.Add(ComboB ox1.Select edItem.ToS tring())
///do something else?!
End Sub
The above event adds a selected item in ComboBox1 to ComboBox2
Private Sub resetCombo()
ComboBox2.Items.Clear()
ComboBox2.Items.Add("apple s")
ComboBox2.SelectedIndex = 0
End Sub
You can call the sub above when you want the box to reset and initialize with apples in the display area. 0 is the first item in the list. a negative 1 means no selection has been made.
I hope this helps.
gl,
Lucas
Private Sub ComboBox1_SelectedIndexCha
ComboBox2.Items.Add(ComboB
///do something else?!
End Sub
The above event adds a selected item in ComboBox1 to ComboBox2
Private Sub resetCombo()
ComboBox2.Items.Clear()
ComboBox2.Items.Add("apple
ComboBox2.SelectedIndex = 0
End Sub
You can call the sub above when you want the box to reset and initialize with apples in the display area. 0 is the first item in the list. a negative 1 means no selection has been made.
I hope this helps.
gl,
Lucas
Or instead, if you already initialize apple into the box you can use this
ComboBox2.SelectedIndex = 0
to
ComboBox2.SelectedItem = "apple"
gl,
Lucas
ComboBox2.SelectedIndex = 0
to
ComboBox2.SelectedItem = "apple"
gl,
Lucas
was the information I provided any good?
Lucas
Lucas
Private Sub ComboBox1_SelectedIndexCha
Label1.Text = ComboBox1.SelectedItem.ToS
End Sub
?