/// <summary> /// Gets the input control value. /// </summary> /// <param name="input">Control to return value for.</param> /// <returns>Controls value</returns> protected virtual object GetControlValue(Control input, string valuePropertyName) { ValidatorGetValueEventArgs args = new ValidatorGetValueEventArgs(input, this); OnGetValue(args); if (args.ValueSet) return args.Value; if (_SuperValidator != null) { _SuperValidator.InvokeGetValue(args); if (args.ValueSet) return args.Value; } if (!string.IsNullOrEmpty(valuePropertyName)) { return TypeDescriptor.GetProperties(input)[valuePropertyName].GetValue(input); } if (input is ComboBox) { ComboBox box = (ComboBox)input; return box.SelectedIndex; } else if (input is DevComponents.DotNetBar.Controls.ComboTree) { DevComponents.DotNetBar.Controls.ComboTree cbt = (DevComponents.DotNetBar.Controls.ComboTree)input; return cbt.SelectedIndex; } if (input is DoubleInput) return ((DoubleInput)input).ValueObject; else if(input is IntegerInput) return ((IntegerInput)input).ValueObject; else if (input is DateTimeInput) return ((DateTimeInput)input).ValueObject; object value = input.Text; string text = input.Text; long l = 0; int i = 0; double d = 0; if (long.TryParse(text, out l)) value = l; else if (int.TryParse(text, out i)) value = i; else if (double.TryParse(text, out d)) value = d; return value; }
/// <summary> /// Raises the GetValue event. /// </summary> /// <param name="e">Event arguments.</param> protected virtual void OnGetValue(ValidatorGetValueEventArgs e) { ValidatorGetValueEventHandler handler = GetValue; if (handler != null) handler(this, e); }
internal void InvokeGetValue(ValidatorGetValueEventArgs e) { OnGetValue(e); }