public override void DownButton() { decimal newValue = Value - Increment; var args = new ValueChangingEventArgs(Value, newValue); OnValueChanging(args); oldText = Text; base.DownButton(); oldText = Text; if (args.KeepOldValue) { Value = args.OldValue; } oldValue = Value; }
private ValueChangingEventArgs ParseText() { try { // VSWhidbey 173332: Verify that the user is not starting the string with a "-" // before attempting to set the Value property since a "-" is a valid character with // which to start a string representing a negative number. if (!string.IsNullOrEmpty(Text) && !(Text.Length == 1 && Text == "-")) { Decimal newValue; if (Hexadecimal) { newValue = Convert.ToDecimal(Convert.ToInt32(Text, 16)); } else { newValue = Decimal.Parse(Text, CultureInfo.CurrentCulture); } if (!constraintsCorrection) { if ((newValue > Maximum) || (newValue < Minimum)) //if ((newValue != Maximum) && (newValue != Minimum)) { constraintsCorrection = true; } var args = new ValueChangingEventArgs(oldValue, newValue); OnValueChanging(args); return(args); } } } catch { // Leave value as it is } return(null); }