C control validating event

Data input validation in Windows Forms is essential.

Built-in validation doesn't go much further than an enforcable maximum length for textboxes, but there are some nice methods you can use to make validation a breeze.

You will find as you tab through the textboxes on the form, that you will get the error icon appearing unless you enter data in the right format.

Hovering the mouse over the error icon will tell you what is wrong and how to fix it.

c control validating event-22c control validating event-13

You can also display a custom error image instead of the default image. This article should not be construed as a best practices white paper.

So what we need is a method of unobtrusively showing that data is invalid, and presenting it in such a way that it is immediately obvious what is wrong and what to do about it.

This little Gem is often left unnoticed, which is a funny thing considering it sits in the Windows Forms Controls Toolbox by default.

However, I also have a bunch of custom controls -they inherit from User Control class- that are like self-contained entities which are composed of multiple stock controls.

When I tried to drop the validator component on my User Control I got a designer exception complaining that it was not a Form, some casting problem.

Text Box Friend With Events txt Last Name As System.

You must have an account to comment. Please register or login here!