Re: ComboBox ItemData?
From: Peter Foot [MVP] (feedback_at_no-spam.inthehand.com)
Date: 10/19/04
- Next message: Alex Feinman [MVP]: "Re: ComboBox ItemData?"
- Previous message: Alex Feinman [MVP]: "Re: Connection Manager - Disconnect"
- In reply to: Tim Johnson: "ComboBox ItemData?"
- Next in thread: Alex Feinman [MVP]: "Re: ComboBox ItemData?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 19 Oct 2004 08:41:35 +0100
You can bind the ComboBox to any custom object collection which exposes at
least the IEnumerable interface. You can then retrieve one of these custom
objects using the SelectedValue property. Another alternative is to use a
DataTable which you have filled from a database. You can specify which
property/field is used to display in the ComboBox as by default it will use
the objects ToString method. For a Customer you might use
comboBox1.DisplayMember = "CustomerName";
comboBox1.DataSource = customers;
Peter
-- Peter Foot Windows Embedded MVP www.inthehand.com | www.opennetcf.org Do have an opinion on the effectiveness of Microsoft Windows Mobile and Embedded newsgroups? Let us know! https://www.windowsembeddedeval.com/community/newsgroups "Tim Johnson" <tjohnson@high-point.com> wrote in message news:eU55kFatEHA.1404@TK2MSFTNGP11.phx.gbl... > I'm coming from MFC-land where a combobox had an ItemDataPtr property, > whereby you could stash away a ptr to some arbitrary object. Then when > the > user selected an item, you could fetch the object back based on the > selected > index. Is there anything comparable in C#? The only samples I've seen > show > them managing their own separate arraylist corresponding to the items in > the > combobox - yechh! > > -- > Tim Johnson > High Point Software > www.high-point.com > (503) 312-8625 > >
- Next message: Alex Feinman [MVP]: "Re: ComboBox ItemData?"
- Previous message: Alex Feinman [MVP]: "Re: Connection Manager - Disconnect"
- In reply to: Tim Johnson: "ComboBox ItemData?"
- Next in thread: Alex Feinman [MVP]: "Re: ComboBox ItemData?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|