C # how to add the WinFrom ErrorProvider Control,
C # how to add the WinFrom ErrorProvider Control
Using System;
Using System. Collections. Generic;
Using System. ComponentModel;
Using System. Data;
Using System. Drawing;
Using System. Linq;
Using System. Text;
Using System. Threading. Tasks;
Using System. Windows. Forms;
Namespace _ 13. _ 12_ErrorProvider Control
{
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
Private void textBox1_TextChanged (object sender, EventArgs e)
{
If (textBox1.Text. Length <8 | textBox1.Text. Length> 10)
{
ErrorProvider1.SetError (textBox1, "the user name must be 8 ~ 10 digits ");
}
Else
{
ErrorProvider1.SetError (textBox1, "verified ");
ErrorProvider1.Icon = new Icon (@ "D: \ ICO \ dks. ico ");
}
}
Private void textBox2_TextChanged (object sender, EventArgs e)
{
If (textBox2.Text. Length <6)
{
ErrorProvider2.SetError (textBox2, "the user password must be greater than 6 characters ");
}
Else
{
ErrorProvider2.SetError (textBox2, "verified ");
ErrorProvider2.Icon = new Icon (@ "D: \ ICO \ icon. ico ");
}
}
Private void textBox3_TextChanged (object sender, EventArgs e)
{
If (textBox3.Text! = TextBox2.Text)
{
ErrorProvider3.SetError (textBox3, "the second user password must be consistent ");
}
Else
{
ErrorProvider3.SetError (textBox3, "verified ");
ErrorProvider3.Icon = new Icon (@ "D: \ ICO \ GameIcon. ico ");
}
}
Private void button#click (object sender, EventArgs e)
{
MessageBox. Show ("registered successfully", "system prompt ");
Application. Exit ();
}
}
}
1. Add the ErrorProvider control to the view