Re: ComboBox ItemData?
From: Alex Feinman [MVP] (public_news_at_alexfeinman.com)
Date: 10/19/04
- Next message: Alex Feinman [MVP]: "Re: Tablet PC"
- Previous message: Peter Foot [MVP]: "Re: ComboBox ItemData?"
- In reply to: Tim Johnson: "ComboBox ItemData?"
- Next in thread: Ginny Caughey [MVP]: "Re: ComboBox ItemData?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 19 Oct 2004 00:44:04 -0700
In CF you need to approach this from the other end. Instead of adding
strings, add objects (or structures). The Combobox will use .ToString() on
each item to display it. You can create a structure, overrride its
ToString() and use it to populate combobox.
Alternatively an ArrayList of objects/strctures can be used as DataSource.
In this case the DisplayMember and ValueMember will be property names to
retrieve from the element
Finally use Combobox.SelectedItem to retrieve the selected item
-- Alex Feinman --- Visit http://www.opennetcf.org "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: Tablet PC"
- Previous message: Peter Foot [MVP]: "Re: ComboBox ItemData?"
- In reply to: Tim Johnson: "ComboBox ItemData?"
- Next in thread: Ginny Caughey [MVP]: "Re: ComboBox ItemData?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|