Fill Combo with Text and Value how?

  • Thread starter Thread starter Roger
  • Start date Start date
R

Roger

I want to fill a combo box with a Text value to show like name, but when it
is selected I want to get the say SS# or Emp #.

I will be filling this in manually how should I go about this.

I know

combo1.items.add(Item)

But what I don't get is how to assign both the text and value at the same
time.

Thanks,

Rog
 
ListItem is not a valid object for me. What do I need to use to clarify it.
Is it a
ListviewItem?

Thanks,

Roger
 
Roger said:
I want to fill a combo box with a Text value to show like name, but when it
is selected I want to get the say SS# or Emp #.

I will be filling this in manually how should I go about this.

I know

combo1.items.add(Item)

But what I don't get is how to assign both the text and value at the same
time.

\\\
Me.ComboBox1.Items.Add(New Person("Pink Panther", 22)

' Test.
MsgBox(DirectCast(Me.ComboBox1­.Items(0), Person).ToString())
..
..
..
Public Class Person
Private m_Name As String
Private m_Age As Integer

Public Sub New(ByVal Name As String, ByVal Age As Integer)
Me.Name = Name
Me.Age = Age
End Sub

Public Property Name() As String
Get
Return m_Name
End Get
Set(ByVal Value As String)
m_Name = Value
End Set
End Property

Public Property Age() As Integer
Get
Return m_Age
End Get
Set(ByVal Value As Integer)
m_Age = Value
End Set
End Property

Public Overrides Function ToString() As String
Return Me.Name & " (" & Me.Age.ToString() & ")"
End Function
End Class
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top