private void Extension_UpDownButtonClick(object sender, UpDownButtonClickEventArgs e)
 {
     if (sender is not C1NumericEdit numericBox)
     {
         return;
     }
     if (numericBox.Value is null)
     {
         numericBox.Value = e.Delta;
     }
 }
Esempio n. 2
0
        protected override void OnUpDownButtonClick(
            UpDownButtonClickEventArgs e)
        {
            base.OnUpDownButtonClick(e);
            if (e.Done)
            {
                return;
            }

            var tvi = ParseContent();

            if (tvi == null)
            {
                return;
            }
            decimal numValue;

            if (Utils.IsNumber(tvi))
            {
                numValue = Utils.AsDecimal(tvi);
            }
            else
            {
                return;
            }
            decimal newNumValue;

            if (e.Delta > 0)
            {
                newNumValue = numValue + _increment;
            }
            else
            {
                newNumValue = numValue - _increment;
            }
            if (_minValue.HasValue && newNumValue < _minValue.Value)
            {
                return;
            }
            if (_maxValue.HasValue && newNumValue > _maxValue.Value)
            {
                return;
            }

            bool caught = false;

            try
            {
                SetProposedValue(ToDataTypeValue(newNumValue));
            }
            catch (Exception)
            {
                caught = true;
            }
            if (caught || ParseContent() == null)
            {
                SetProposedValue(tvi);
            }
            else if (RightToLeft == RightToLeft.Yes)
            {
                Select(base.Text.Length, 0);
            }
        }