public static void SelectByValue(this ComboBox comboBox, object value) { IComboBoxAdapter adapter = comboBox.DataSource as IComboBoxAdapter; if ((value == null) && (adapter != null) && adapter.ContainsNull) { comboBox.SelectedIndex = 0; return; } comboBox.SelectedValue = value; }
public static void SetAdapterAsDataSource(this ComboBox comboBox, IComboBoxAdapter adapter) { comboBox.DataSource = adapter; comboBox.ValueMember = "Value"; comboBox.DisplayMember = "Label"; }