Gotcha! I understand now and yes there is a beautiful solution for this. First off I want to mention that your closing code tag needs the forward slash in order to work.

Ok, now the beautiful solution. In .NET everything is treated as an object. You can create an object say "contact" which has properties like "telephone" and "name". Great, with me so far? One of the methods you can also give it is ToString() which represents a text representation of the object. It would be used like...
CODE
Dim jimmy as new Contact
jimmy.telephone = "1234 567 890"
jimmy.email = "someone@somewhere.co.uk"
' Print out the contact info
' It would messagebox something like "Jimmy - Telephone: 1234 567 890 Email: someone@somewhere.co.uk"
MessageBox.Show(jimmy.ToString())
Of course you override ToString and give it this functionality. Ok, got this bit alright? Good.
You can then add objects to your combo. The combo box will then use the info returned by the ToString method as the text for the item. So if we were to stick Jimmy into the combo box, the value "Jimmy - Telephone: 1234 567 890 Email: someone@somewhere.co.uk" would be printed in the combobox list.
The idea though is that it remains an object. So you can actually reference the combobox items as you normally would, but if you were fetch the item out you could use it as the original object... a Contact. You would just have to cast it out.
Here is an example of the contact class....
CODE
Public Class Contact
Private Thename As String
Private Thetelephone As String
Private Theemail As String
' Constructor
Public Sub New(ByVal name As String, ByVal telephone As String, ByVal email As String)
Thename = name
Thetelephone = telephone
Theemail = email
End Sub
' Property we can use to set the Telephone number
Public Property Telephone()
Get
Return Thetelephone
End Get
Set(ByVal value)
Thetelephone = value
End Set
End Property
' Notice this "overrides" the ToString to create our own ToString
Public Overrides Function ToString() As String
Return Thename & " - " & Thetelephone & " - " & Theemail
End Function
End Class
Notice we implement a constructor for building the contact, a property for reading and setting the telelphone and another that overrides the toString method to show us the contacts name, telephone and email.
So lets add this to a combo....
CODE
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim jimmy As New Contact("Jimmy", "1234 567 890", "someone@somewhere.co.uk")
ComboBox1.Items.Add(jimmy)
End Sub
Notice how I make a copy of the contact object and set it to Jimmy's content. I then simply add this object to the combo. It now shows one item in the combo with the contact info in it. Great! But how do we get at it again? Well we simply cast it back to a Contact object and we can get access. Here is an example...
CODE
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Create a contact instance variable
Dim blankContact As Contact
' Fetch the item from the combobox like any other item, but cast it to type "Contact" using Ctype
blankContact = CType(ComboBox1.Items.Item(0), Contact)
' Print the contacts phone number... which will be Jimmy's since he is the first item in our combo.
MessageBox.Show(blankContact.Telephone)
End Sub
With this ability you can essentially take Jimmy out of the combo, modify his settings, put him back in. You can loop through the combo, ask each item to spit out its Telephone and stick it in the textbox. This allows you to modify elements at runtime, add to them, everything you can do with an object at runtime and show the latest changes.
Hope that helps you out! Enjoy!
"At DIC we be object manipulating son of a gun code ninjas!"
This post has been edited by Martyr2: 1 Feb, 2008 - 01:29 PM