Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

In VB6 these controls had a very useful ItemData property, that I would use to hold an ID. With the new version .Net these controls have been changed and this property is no longer available.

 

When my form loaded the control would display all my contacts (list would hold the Person Name and the ItemData property would hold the ID), when I selected a person the ID would be passed from the ItemData property to the method that brought back complete details about that person.

 

Is there a technique with the .Net Combobox control that would allow me to continue with this approach?

 

Thanks

 

Brent

  • *Gurus*
Posted
The Add method of the Items collection takes an Object type, in other words anything. Create a class that is able to hold the data that you need for each item and add that to the Items collection instead of a string. Just make sure the class overrides ToString, as that is what will be displayed in the ListBox/ComboBox.
Posted

Hi Derek.

 

I tried that earlier.

 

In the Combobox control I had the name and ID displaying, by overridding my object's ToString() method (as you mentioned), then I just extracted the ID portion out when I selected the person from the list.

 

So this is the best approach? This will work fine, but I had grown to like the the old ItemData property...

 

Thanks for the reply....its good to know that I'm on the correct track.

 

Brent

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...