Hi,
Bind to an arraylist filled with a class that holds the data you
want.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim ar As New ArrayList
ar.Add(New ComboItems("Dog", 1))
ar.Add(New ComboItems("Cat", 2))
ar.Add(New ComboItems("Mouse", 3))
ComboBox1.DataSource = ar
ComboBox1.DisplayMember = "Animal"
ComboBox1.ValueMember = "Val"
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e
As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
Dim ci As ComboItems
Try
ci = DirectCast(ComboBox1.SelectedItem, ComboItems)
Debug.WriteLine(String.Format("Display {0} Value {1}", ci.Animal, ci.Val))
Catch ex As Exception
End Try
End Sub
The class
Public Class ComboItems
Private mstrAnimal As String
Private mintVal As Integer
Public Property Animal() As String
Get
Return mstrAnimal
End Get
Set(ByVal Value As String)
mstrAnimal = Value
End Set
End Property
Public Property Val() As Integer
Get
Return mintVal
End Get
Set(ByVal Value As Integer)
mintVal = Value
End Set
End Property
Public Sub New(ByVal MyAnimal As String, ByVal MyVal As Integer)
mintVal = MyVal
mstrAnimal = MyAnimal
End Sub
End Class
Ken
--------------------------------------
I have an arrar something like this:{{"Dog", "Cat", "Mouse"},{"1", "2",
"3"}}
I want to enter all thos into a combo box (dropdown list) so that Item "Dog"
has a value of 1, and so on.
How do i iterate trough that array in order to :
Items.Add ("1", "Dog"), etc...
Thanks.