Brent Alan Posted November 3, 2002 Posted November 3, 2002 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 Quote
*Gurus* Derek Stone Posted November 3, 2002 *Gurus* Posted November 3, 2002 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. Quote Posting Guidelines
Brent Alan Posted November 3, 2002 Author Posted November 3, 2002 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 Quote
*Gurus* Derek Stone Posted November 3, 2002 *Gurus* Posted November 3, 2002 We all grew to like the cheap crap VB6 gave to us. I stress "cheap crap". :) Quote Posting Guidelines
Moderators Robby Posted November 3, 2002 Moderators Posted November 3, 2002 I agree with Derek...it was "cheap crap". The .net combo/list is much more powerful. Quote Visit...Bassic Software
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.