Hi,
I am using the checked list box to display my list but I have 2 columns, ID
and Name. I want the ID to be hidden and used in the SelectedIndexChanged
method to populate another ListBox. I cannot see how to do this with this
control?
Anyone can help me in the right direction?
Thanks.
Claes Bergefall - 05 Oct 2005 09:48 GMT
Put custom objects in the listbox, where each object implements a
Name and an ID property:
Public Class MyData
Private m_name As String
Private m_id As Integer
Public Sub New(name As String, id As Integer)
m_name = name
m_id = id
End Sub
Public Property Name As String
Get
Return m_name
End Get
Set(value As String)
m_name = value
End Set
End Property
Public Property ID As Integer
Get
Return m_id
End Get
Set(value As Integer)
m_id = value
End Set
End Property
Public Overrides Function ToString() As String
Return Name
End Function
End Class
...
myListBox.Items.Add(New MyData("peter", 248745))
...
Dim data As MyData = CType(myListBox.SelectedItem, MyData)
'Do stuff with myData.Name and MyData.ID
/claes
> Hi,
>
[quoted text clipped - 6 lines]
>
> Thanks.