ComboBox - adding item data
I know how to add data to combo boxes in C++, along with it's item data, but
in C# I am having trouble getting more then a combo box with text. I need
to be able to click on the combobox item and have a value that I can query a
record with. Any ideas?
Re: ComboBox - adding item data
In article <firstname.lastname@example.org> (from Mike <email@example.com>),
> I know how to add data to combo boxes in C++, along with it's item data, but
> in C# I am having trouble getting more then a combo box with text. I need
> to be able to click on the combobox item and have a value that I can query a
> record with. Any ideas?
The "Items" collection now accepts an "Object" type, not a string.
Therefore, you can place whatever you want in the ListBox.
For example, you could have a class that has 3 or 4 members like "Name",
"Age", "DateOfBirth" and "ID". Simply add this class to the listbox as:
The listbox stores a reference to the class and then uses the
"ToString" method of the class to populate the display of the listbox.
You can override the ToString method to change what appears or you can
set the "DisplayMember" property to tell the listbox what property to
pick for display (Example: ListBox1.DisplayMember = "DateOfBirth").
Microsoft .NET MVP
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL