• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

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
0
LuckyLucks
Asked:
LuckyLucks
  • 3
  • 2
1 Solution
 
Carl TawnSystems and Integration DeveloperCommented:
You mean something like:

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Label1.Text = ComboBox1.SelectedItem.ToString()
    End Sub


?
0
 
LuckyLucksAuthor Commented:
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"
0
 
Carl TawnSystems and Integration DeveloperCommented:
You mean you want to programmatically select an item from the list ?

Something like:

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ComboBox1.SelectedText = "apples"
    End Sub

?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
KudzullcCommented:
hi LuckyLucks,

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

ComboBox2.Items.Add(ComboBox1.SelectedItem.ToString())

///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("apples")
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

0
 
KudzullcCommented:
Or instead, if you already initialize apple into the box you can use this

ComboBox2.SelectedIndex = 0

to

ComboBox2.SelectedItem = "apple"


gl,
Lucas
0
 
KudzullcCommented:
was the information I provided any good?

Lucas
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now