public void SetCombos(string value, System.Windows.Forms.ComboBox combo1, System.Windows.Forms.ComboBox combo2) { if (value.Length > 0) { if (value.Split(',').Length == 2) { combo1.SelectedIndex = combo1.FindString(value.Split(',')[0]); combo2.SelectedIndex = combo2.FindString(value.Split(',')[1]); } else { combo1.SelectedIndex = combo1.FindString(value); } } }
public void SetCombosFormatMoney(string value, System.Windows.Forms.ComboBox combo1, System.Windows.Forms.ComboBox combo2) { if (value.Length > 0) { if (value.Split(',').Length == 2) { var t1 = Convert.ToDecimal(value.Split(',')[0]).ToString("C"); var t2 = Convert.ToDecimal(value.Split(',')[1]).ToString("C"); combo1.SelectedIndex = combo1.FindString(t1); combo2.SelectedIndex = combo2.FindString(t2); } else { var t1 = Convert.ToDecimal(value).ToString("C"); combo1.SelectedIndex = combo1.FindString(t1); } } }
private static void SetComboBoxString(System.Windows.Forms.ComboBox cb, string sText) { int idx = cb.FindString(sText); if (idx == -1) { Styx.Helpers.Logging.Write("Dialog Error: combobox {0} does not have value '{1}' in list", cb.Name, sText); idx = cb.FindString("Auto"); if (idx == -1) { Styx.Helpers.Logging.Write("Dialog Error: combobox {0} does not have an 'Auto' value either, defaulting to first in list", cb.Name); idx = 0; } } cb.SelectedIndex = idx; }
public static void SetComboboxSelectedByValue(System.Windows.Forms.ComboBox cbx, object value) { cbx.SelectedIndex = cbx.FindString(value.ToString()); }
/// <summary> /// Checks if a Combobox Text is equal the selected item. /// </summary> /// <param name="AComboBox">ComboBox Control that should be verified.</param> /// <returns>TVerificationResult Nil if validation succeeded, otherwise it contains /// details about the problem. /// </returns> public static TVerificationResult ValidateStringComboBox(System.Windows.Forms.ComboBox AComboBox) { TVerificationResult ReturnValue = null; if (AComboBox.SelectedItem == null) { ReturnValue = new TVerificationResult(AComboBox.Name, ErrorCodes.GetErrorInfo( CommonErrorCodes.ERR_INFORMATIONMISSING, StrNoItemSelected)); } if (AComboBox.FindString(AComboBox.Text) != AComboBox.SelectedIndex) { ReturnValue = new TVerificationResult(AComboBox.Name, ErrorCodes.GetErrorInfo( CommonErrorCodes.ERR_INFORMATIONMISSING, StrNonExistingItem)); } return ReturnValue; }