C # how to add the WinFrom ErrorProvider Control,

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.