Fill ComboBox from ArrayList VB.Net
'Dim data as ArrayList = new ArrayList
' data is 2d arraylist
' cmbMain is ComboBox
Dim choices = New Dictionary(Of String, String)()
For i As Integer = 0 To data.Count - 1
choices(data.Item(i).Item(0)) = data.Item(i).Item(1)
Next
cmbMain.DataSource = New BindingSource(choices, Nothing)
cmbMain.DisplayMember = "Value"
cmbMain.ValueMember = "Key"
' data is 2d arraylist
' cmbMain is ComboBox
Dim choices = New Dictionary(Of String, String)()
For i As Integer = 0 To data.Count - 1
choices(data.Item(i).Item(0)) = data.Item(i).Item(1)
Next
cmbMain.DataSource = New BindingSource(choices, Nothing)
cmbMain.DisplayMember = "Value"
cmbMain.ValueMember = "Key"
Comments
Post a Comment