private void ComboBoxEx_TextChanged(object sender, EventArgs e) { ComboBoxEx cbo = sender as ComboBoxEx; if (cbo.FindStringExact(cbo.Text) < 0) { _error.SetError(cbo, "不可以指定清單以外的值"); } else { _error.SetError(cbo, ""); } }
public static void SelectItem(this ComboBoxEx cmb, string text) { int index = cmb.FindStringExact(text); if (index > -1) { cmb.SelectedIndex = index; return; } else { if (cmb.Items.Count > 0) { cmb.SelectedIndex = 0; } } }