loading a combobox with Listarray

bob.walker

Member
Joined
May 17, 2005
Messages
18
Programming Experience
3-5
when running program I can see all 9 items of data are loaded into myComboBox, but when it displays on the screen all I get is 9 instances of "Test1.Global+ListCodes". What do I need to use in the DisplayMember spot?
I've tried original field name of "Name1", "test.codeName"

PublicStructure ListCodes
Public codeName AsString
Public codeValue AsString
EndStructure

...
Dim myData AsNew ArrayList
Dim test As ListCodes

While myReader.Read()
test = New ListCodes
test.codeName = myReader.Item(0)
test.codeValue = myReader.Item(1)
myData.Add(test)
EndWhile

myComboBox.DataSource = myData
myComboBox.DisplayMember = ??????

 
Last edited:
First of all, in your structure try to provide properties of your both fields
like Name , CodeValue and then you have to implement your own custome collection class
like
Public Class ListCodesCollection inherits CollectionBase
'then override two methods into the class i.e.
Public Sub Add ( c as ListCodes)
_myBase.InnerList.Add(c)
End Sub
Public Default Property Item(index As Integer) As ListCodes
Get
Return MyBase.InnerList(index)
End Get
Set (value As Customer)
_MyBase.InnerList(index) = value
End Set
End Property
End Class


Now when setting up the Data source use the following statement
comboBox1.DataSource = list 'where list is an instance of ur own collection class
comboBox1.DisplayMember = "Name";
'where Name is property in your structure
 
Back
Top