text的跳转并验证

来源:岁月联盟 编辑:zhu 时间:2004-11-23
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 ("输入无效!,只允许输入数字");
}
}
}