Datagridview onvalidating

The Validating event is the one that handles most of the validation logic.

This event defines an event argument (Cancel Event Args) which contains the Boolean property named Cancel to set a signal that the event being fired should not be completed.

Setting this property to True is a signal back to the control that the validation failed in the code that handles the event and this results that the focus won't leave the control, forcing the user to enter a correct value.

Setting this property to False allows the validation process to continue.

This eliminates the possibility the end-users will incorrectly enter the values.

The refining of the data is done later, when the data is passed to another layer for processing.

In this article, I will cover the principles and techniques built into Microsoft.

Some checks are business rules and thus conceptually they must be done in the business layer of the multi-layer application or in the server-side of a client/server application.

Introduction An important part of any data-driven application is ensuring data validation and handling errors when they occur.

Validation means that any data input meets the application requirements in order to ensure consistency and correctness of the data.

A problem with this approach is that if the users enter an invalid value and tries to close the application, by default, they won't be able to do it. NET 2.0, we have the Auto Validate property on the Form class that lets you specify exactly what the behavior should be when the validation error occurs at the control level.

The Auto Validate property may have four values: Disable, Enable Prevent Focus Change, Enable Allow Focus Change, Inherit. If you set Enable Prevent Focus Change value and Cancel is set to true, focus will remain on the control that failed the validation.

Leave a Reply