The trick is to define your own class to hold these in and override the
ToString method, see below for an example. We Define our own nested class in
the form ( does not have to be nested ) and implement it. In the load event
we create three objects of this type and add them to the ComboBox, in the
button event, we simply print them out.
So you could add SelectedIndex changed event to the combo box to do
something with the selected object.
HTH
Class MyListObject
Private m_SCode As String
Private m_ExRate As Double
Private m_Description As String
Public Overrides Function ToString() As String
Return m_Description
End Function
Public Sub New(ByVal iSCode As String, ByVal iExRate As Double,
ByVal iDescription As String)
m_SCode = iSCode
m_ExRate = iExRate
m_Description = iDescription
End Sub
Public Property SCode() As String
Get
Return (m_SCode)
End Get
Set(ByVal Value As String)
m_SCode = Value
End Set
End Property
Public Property Description() As String
Get
Return m_Description
End Get
Set(ByVal Value As String)
m_Description = Value
End Set
End Property
Public Property ExRate() As Double
Get
Return m_ExRate
End Get
Set(ByVal Value As Double)
m_ExRate = Value
End Set
End Property
End Class
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim i1 As New MyListObject("PST", 200.0, "Pesatas")
Dim i2 As New MyListObject("DEN", 177.0, "Denar")
Dim i3 As New MyListObject("DOL", 1.75, "Dollar")
ComboBox1.Items.Add(i1)
ComboBox1.Items.Add(i2)
ComboBox1.Items.Add(i3)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'List all entries
Dim i As Int32
Dim o As MyListObject
For i = 0 To ComboBox1.Items.Count - 1
o = DirectCast(ComboBox1.Items(i), MyListObject)
Debug.WriteLine("ShortCode=" & o.SCode & ", ExRate=" & o.ExRate
& ", Desc=" & o.Description)
Next
End Sub
--
OHM ( Terry Burns )
. . . One-Handed-Man . . .
Time flies when you don't know what you're doing