开发者

Shared DataSource between combobox and textbox

开发者 https://www.devze.com 2023-04-07 08:45 出处:网络
I have this three controls: ComboBox: list of myob开发者_StackOverflow中文版ject TextBox: view a description

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消