The ComboBox class provides DisplayMemberPath and ItemsSource properties to bind the control to data. The DisplayMemberPath property sets the path to a value on the source object for displaying data, and the ItemsSource property lets you bind the control to a collection of items.
The following code snippet illustrates how to set these properties in code to achieve data binding.
C# |
Copy Code
|
---|---|
var array = States.GetStates(); cbxEdit.ItemsSource = array; cbxEdit.DisplayMemberPath = "Name"; |