Q: Listbox Control Item - Multiple Names (and/or variables)? I have a lot of data that's coming from a database and being adding to a listbox. The data that's coming from the database is a unique ID, and a name. 
Is there any way I can make the item contain both the ID and name? I know I can append it, that's not what I'm looking to do. I need a way to be able to either get the ID, or get the name, while displaying them both.
I have gotten as far as creating a class:
Class Item
    Property ID as Integer
    Property Name as String

    Sub New(ID as Integer, Name as String)
        Me.ID = ID
        Me.Name = Name
    End Sub

    Overrides Function ToString() as String
        Return Name
    End Function
End Class

That looks like it should do the trick, but I'm having trouble getting the ID, instead of the name. To put it simply, I wish I could do this: listbox1.selecteditem(id) to get the id, or listbox1.selecteditem(name) to get the name.
Any ideas on how to implement this?

A: You can bind to a List(Of Item) like this:
Dim ItemList = New List(Of Item)
' Fill the list with appropiate values.'
listbox1.DataSource = ItemList
listbox1.DisplayMember = "Name"
listbox1.ValueMember = "ID"

Then listbox1.SelectedValue holds the ID and you can access the name like this:
DirectCast(listbox1.SelectedItem, Item).Name

If you want to show both the ID and the Name, then I suggest you add a property to be the displayed value in the Itemclass:
Public ReadOnly Property DisplayedValue() as String
    Get
        Return Me.Name & " (" & Me.ID.ToString & ")"
    End Get
End Property

Then when binding the list make
 listbox1.DisplayMember = "DisplayedValue"

Update:
Based on your comments below I'd say my solution still works. However with this methodology the items must be added to the list and then the list bound to the object. The items can not be added individually and directly to the list box (as you would be separating data from presentation I don't see that as a problem).
To show a message box with the selected item then you just need to do:
MessageBox.Show(DirectCast(listbox1.SelectedItem, Item).ID.ToString))


A: I think you'll have to write a helper method to do this. If you're using VB 3.5 or newer (part of VS2008 and newer) you can write an extension method so that you can at least get nice syntax. You could write one such that it looked like:
listbox1.SelectByID(123)
listbox1.SelectByName("hello")

In the methods you'd have some search algorithm that went through the items and found the right one.
