Step 1: Open Visual Studio (any version) installed in your machine. I have VS2012,

Open

Click New Project. This opens a new window which looks like the image below.

New project

Step 2: Enter your application name and click OK.

application Name

Step 3: Design your Windows application - Drag and drop one textbox, one button, one label and errorProvider. Click the button and add the source code.

Design

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Diagnostics;
  11. using System.ComponentModel;
  12. using System.Text;
  13. namespace Error2
  14. {
  15. public partial class Form1 : Form
  16. {
  17. public Form1()
  18. {
  19. InitializeComponent();
  20. }
  21. private void button1_Click(object sender, EventArgs e)
  22. {
  23. if (textBox1.Text == "krishna")
  24. {
  25. errorProvider1.Clear();
  26. MessageBox.Show("This is Valid Data");
  27. }
  28. else
  29. {
  30. errorProvider1.SetError(textBox1,"please enter correct data");
  31. MessageBox.Show("please enter correct data");
  32. errorProvider1.BlinkStyle = ErrorBlinkStyle.BlinkIfDifferentError;
  33. }
  34. }
  35. }
  36. }
Output will be the following screenshots

Outputs

Outputs