text的跳转并验证

类别:.NET开发 点击:0 评论:0 推荐:

 using System.Text .RegularExpressions;

 

private void txtChequeCode_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  {
   if(e.KeyCode == Keys.Enter )
   {
    if(Regex.Match (this.txtChequeCode .Text .Trim (),@"^\d+$").Success )
    {
     this.txtChequeSum .Focus ();
     this.txtChequeSum .Select ();
    }
    else
    {
     MessageBox.Show ("输入无效!,只允许输入数字");
    }
   }
  }

  private void txtChequeSum_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  {
   if(e.KeyCode == Keys.Enter )
   {
    if(Regex.Match (this.txtChequeSum .Text .Trim (),@"^\d+$").Success )
    {
     this.ButtonSave .Focus ();
     this.ButtonSave .Select ();
    }
    else
    {
     MessageBox.Show ("输入无效!,只允许输入数字");
    }
   }
  }

本文地址:http://com.8s8s.com/it/it42788.htm