We need you!

We're working hard on the next version of Developer Fusion. Let us know what you think we should be up to!

Members

Technology Zones

Articles

Hosted By

MaximumASP

Info

Rated
Read 21,832 times

Related Categories

Data Entry Validation with Error Provider

Rollershade

To use this code, simply drag the errorProvider control onto the form, it appears in the list as a red exclamation mark. Add one textbox and one command button, now use this code in the button click event

private void button1_Click(object sender, System.EventArgs e)
{
    //CHECK FOR DATA ENTRY
    if(textBox1.Text =="")
    {
        //NO DATA!
        errorProvider1.SetError(textBox1,"You need to enter a value");
    } else {
        //DATA ENTERED DONT SHOW THE ERROR WITH ""
        errorProvider1.SetError(textBox1,"");
    }
}


You set the error icon active if the data validation is not meet, in this case its if there is no text in the textbox, to hide the errorprovider again simply just include "" instead of putting text in the seterror. You can set the BlinkStyle of the provider to NeverBlink, AlwaysBlink and BlinkIfDifferentError.You can set those by the properties view in design time or in code in runtime. You can also change the icon at design time to whichever icon you like.

I am 25 and live in west Sussex. I enjoy drinking and going out, but I also enjoy writing programs + creating websites in my free time. I play golf and ski.

One of my main intrests when not drinking ;) is programming , the tv can get boring as hell, i first started programming with HTML in 1996 ish and in early 1998 i started learning Visual Basic, i am now learning C#.NET frm Jan 2004. I have continued to learn and gain valuable knowledge from the vb diploma i have completed. While learning vb i became a member of this here Developerfusion.com which i have now become a Moderator at. Examples of my previous projects like WebEdit and EasyCSS can be found on my website.

Comments

  • Re: error provider

    Posted by Karloz on 14 Feb 2008

    You must create validated event for the component, example: 


      Private Sub myTextBox_Validated(ByVal sender As System.Object, ByVal e As System.Eve...

  • multiple error messages

    Posted by M3L on 24 Jun 2004

    How can I do multiple error messages for multiple validations in ONE message box, instead of having each error message each message box for each validations?

    Thank you

  • error provider

    Posted by vasu on 13 Feb 2004

    I want to erase the error provider symbol after blinking how can i do it?