コード例 #1
0
ファイル: Form1.cs プロジェクト: petrnohejl/Mas-na-to
        private void inputBox_Validating(object sender, InputBoxValidatingArgs e)
        {
            // retezec neni cislo
            try
            {
                System.Convert.ToInt32(e.Text);
            }
            catch
            {
                e.Cancel = true;
                e.Message = "NAN";
            }

            // prazdny retezec
            if (e.Text.Trim().Length == 0)
            {
                e.Cancel = true;
                e.Message = "Required";
            }
        }
コード例 #2
0
ファイル: InputBox.cs プロジェクト: petrnohejl/Mas-na-to
 /// <summary>
 /// Validate the Text using the Validator
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void textBoxText_Validating(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (Validator != null)
     {
         InputBoxValidatingArgs args = new InputBoxValidatingArgs();
         args.Text = textBoxText.Text;
         Validator(this, args);
         if (args.Cancel)
         {
             e.Cancel = true;
             errorProviderText.SetError(textBoxText, args.Message);
         }
     }
 }