Combobox and text box in vb2010

  • Thread starter Thread starter Anburose
  • Start date Start date
A

Anburose

Guest
Dear Friend

i use 1-comboBox, 1-TextBox , 2-Button

my code

Public Class Form1

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim comboSource As New Dictionary(Of Integer, String)()
comboSource.Add(25, "Anbu")
comboSource.Add(20, "Rose")
comboSource.Add(45, "Siva")
comboSource.Add(75, "Srini")
comboSource.Add(60, "Nazar")
comboSource.Add(40, "Sakthi")
comboSource.Add(65, "Vince")

ComboBox1.DataSource = New BindingSource(comboSource, Nothing)
ComboBox1.DisplayMember = "Value"
ComboBox1.ValueMember = "Key"
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim key As String = DirectCast(ComboBox1.SelectedItem, KeyValuePair(Of Integer, String)).Key
Dim value As String = DirectCast(ComboBox1.SelectedItem, KeyValuePair(Of Integer, String)).Value
MessageBox.Show(key & " " & value)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

End Sub
End Class


My Request

if i click button1 then message show combobox display member and value member.

i want , i will give the value member in Textbox, comboBox will display the related display member. what i do?

help me pls.


Thanks

Anburose

Continue reading...
 
Back
Top