1 private void button1_Click(object sender, EventArgs e)
2 {
3 this.errorProvider1.Clear();
4 if (this.textBox1.Text.Length<6||this.textBox1.Text.Length>12)
5 {
6 this.errorProvider1.SetError(this.textBox1, "输入有误");
7 DialogResult dialogresult = MessageBox.Show("你的输入有误", "Error", MessageBoxButtons.OKCancel);
8 switch (dialogresult)
9 {
10 case DialogResult.Cancel:
11 this.textBox1.Text = "你输入有误";
12 break;
13 case DialogResult.OK:
14 this.textBox1.Text = "";
15 break;
16 default:
17 break;
18 }
19 }
20 }