コード例 #1
0
 private void OnInputValidationError(object sender, InputValidationErrorEventArgs e)
 {
     if (this.Child != null)
     {
         CellEditor.SetHasError(( DependencyObject )this.Child, true);
     }
 }
コード例 #2
0
        private void Decimal_InputValidationError(object sender, InputValidationErrorEventArgs e)
        {
            DecimalUpDown dSender = (DecimalUpDown)sender;

            string value = dSender.Text;

            value = value.Replace(',', '.');

            decimal parseValue;

            if (decimal.TryParse(value, NumberStyles.Float, new CultureInfo("en-US"), out parseValue))
            {
                if (parseValue > dSender.Maximum)
                {
                    dSender.Value = dSender.Maximum;
                }
                else if (parseValue < dSender.Minimum)
                {
                    dSender.Value = dSender.Minimum;
                }
                else
                {
                    dSender.Value = parseValue;
                }
            }
        }
コード例 #3
0
 private void RaiseInputValidationError(Exception e)
 {
     if (InputValidationError != null)
     {
         InputValidationErrorEventArgs args = new InputValidationErrorEventArgs(e);
         InputValidationError(this, args);
         if (args.ThrowException)
         {
             throw args.Exception;
         }
     }
 }
コード例 #4
0
        protected override void OnDateValidationError(DatePickerDateValidationErrorEventArgs e)
        {
            base.OnDateValidationError(e);

            // This validation error may have been raised by the "CommitInput()" call.
            // If this is the case, use the _commitException member.
            if (InputValidationError != null)
            {
                InputValidationErrorEventArgs args = (_commitException != null)
          ? new InputValidationErrorEventArgs(_commitException)
          : new InputValidationErrorEventArgs(e.Exception);

                InputValidationError(this, args);
                if (args.ThrowException)
                {
                    throw args.Exception;
                }
            }
        }
コード例 #5
0
ファイル: UpDownBase.cs プロジェクト: rox00/WPF
        protected void SyncTextAndValueProperties(bool updateValueFromText, string text)
        {
            if (_isSyncingTextAndValueProperties)
            {
                return;
            }

            _isSyncingTextAndValueProperties = true;
            Exception error = null;

            if (updateValueFromText)
            {
                try
                {
                    Value = ConvertTextToValue(text);
                }
                catch (Exception e)
                {
                    error = e;
                }
            }

            Text = ConvertValueToText();

            if (TextBox != null)
            {
                TextBox.Text = Text;
            }

            if (updateValueFromText)
            {
                if ((error != null) && (InputValidationError != null))
                {
                    InputValidationErrorEventArgs args = new InputValidationErrorEventArgs(error.Message);
                    InputValidationError(this, args);
                }
            }

            _isSyncingTextAndValueProperties = false;
        }
コード例 #6
0
 private void txt_InputValidationError(object sender, InputValidationErrorEventArgs e)
 {
     Funcoes.Mensagem("Valor Inválido", TituloErro, MessageBoxButton.OK);
 }