Shared DataSource between combobox and textbox
I have this three controls:
ComboBox
: list of myob开发者_StackOverflow中文版ject
TextBox
: view a description
DataSource
: list(of MyObject)
MyObject:
property id as int
property combodesctription as string
property description as string
I want to select an element on the combobox and see the selected object description into the TextBox.
How can I do that ?
You can handle ComboBox1's SelectedIndexChanged event.
If Not IsNothing(ComboBox1.SelectedItem) Then
Dim obj As MyObject = CType(ComboBox1.SelectedItem, MyObject)
TextBox1.Text = obj.Description
End If
//On Combobox Selected Index Change
textbox1.text = Combobox1.Items(1).ToString()
精彩评论