Hello,
"Sebastian Santacroce" <ss*********@ilogic.com> schrieb:
Is there an easy way to store a value with an ID in a drop
down list. ie making it an array and showing only the
value and not an ID. I believe this was possible in VB 6.
So that when they select a value I can get its
corresponding ID that is stored in a database for example.
If not what would be the easiest way to do this?
\\\
Dim p As New Person()
p.Name = "Pink Panther"
p.Age = 22
Me.ComboBox1.Items.Add(p)
MessageBox.Show( _
DirectCast(Me.ComboBox1.Items.Item(0), Person).ToString() _
)
..
..
..
Public Class Person
Private m_strName As Object
Private m_intAge As Integer
Public Property Name() As String
Get
Return m_strName
End Get
Set(ByVal Value As String)
m_strName = Value
End Set
End Property
Public Property Age() As Integer
Get
Return m_intAge
End Get
Set(ByVal Value As Integer)
m_intAge = Value
End Set
End Property
Public Overrides Function ToString() As String
Return m_strName & " (" & m_intAge.ToString() & ")"
End Function
End Class
///
--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet