C#控件储备——错误提示控件errorProvider

错误提示控件errorProvider

 

VS显示:

 

核心代码:

this.errorProvider1.SetError(this.textBox1,"输入有误");

源码:

 1 #region 错误提醒ErrorProvider
 2         private void button1_Click(object sender, EventArgs e)
 3         {
 4             if (textBox1.Text != "")
 5             {
 6                 this.errorProvider1.SetError(this.textBox1,"输入有误");
 7                 DialogResult ReturnDlg = MessageBox.Show(this, "输入有误,是否重新输入", "信息提示", MessageBoxButtons.RetryCancel, MessageBoxIcon.Question);
 8                 switch (ReturnDlg)
 9                 {
10                     case DialogResult.Retry:
11                         this.textBox1.Text = "";
12                         break;
13                     case DialogResult.Cancel:
14                         break;
15                 }
16             }
17         }
18         #endregion
posted @ 2012-07-17 23:15  Ghost Soar  阅读(6508)  评论(0编辑  收藏  举报