dotnetmonitor.com

 
Index
Previous
Next

 

You can fill a ComboBox with non-string items such as business objects. By default, the ComboBox will call ToString() on each of the items to generate the display text (visible text). Rather than rely on ToString(), you can have the ComboBox use one of the properties on the contained objects (business object) as the display text. To do this, set the ComboBox.DisplayMember to the property name you want to use for the display text. You can also set the ValueMember to a property on the contained objects that represents the object unique key. You can then use the ComboBox SelectedValue property to set the ComboBox selected item via object key.
Simple Binding
Complex Binding
Using Simple Binding with a List
Sample: Simple Binding to a List (VS 2005) (VS Project: DataBinding Intro)
Type Conversion
Formatting