You can store any object you like in a combo box, so long as you
implement the ToString() method, the return value from that is what will
get displayed to the user.
For example
Private Sub FillComboMethod()
For i As Integer = 1 To 10
Dim objItem As New MyComboClass
objItem.DisplayText = "Item " & i.ToString()
ComboBox1.Items.Add(objItem)
Next
End Sub
Public Class MyComboClass
Private m_DisplayText As String
Private m_SomeOtherInfo As Integer
Private m_SomeOtherObject As Object
Public Property DisplayText() As String
Get
Return m_DisplayText
End Get
Set(ByVal Value As String)
m_DisplayText = Value
End Set
End Property
Public Property SomeOtherObject() As Object
Get
Return m_SomeOtherObject
End Get
Set(ByVal Value As Object)
m_SomeOtherObject = Value
End Set
End Property
Public Property SomeOtherInfo() As Integer
Get
Return m_SomeOtherInfo
End Get
Set(ByVal Value As Integer)
m_SomeOtherInfo = Value
End Set
End Property
Public Overrides Function ToString() As String
Return DisplayText
End Function
End Class
Kay wrote:
Hi all,
Wondering is there a way to work with .net's combo box like in VB 6's with
the ItemData property? Coz I want to store 2 values for each item in the
combo....
Thanks!
Kay