Skip to main content

BaseEdit.Validate Event

Enables you to validate the editor's value.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v14.2.dll

#Declaration

public event ValidateEventHandler Validate

#Event Data

The Validate event's handler receives an argument of the ValidationEventArgs type. The following properties provide information specific to this event:

Property Description
Culture Gets the culture related to the validation.
ErrorContent Gets or sets an object that describes the validation error.
ErrorType Gets or sets the error type.
Handled Gets or sets a value that indicates the present state of the event handling for a routed event as it travels the route. Inherited from RoutedEventArgs.
IsValid Gets or sets a value specifying whether the value is valid.
OriginalSource Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class. Inherited from RoutedEventArgs.
RoutedEvent Gets or sets the RoutedEvent associated with this RoutedEventArgs instance. Inherited from RoutedEventArgs.
Source Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.
UpdateSource Gets an object that invoked the BaseEdit.Validate event.
Value Gets the editor's new value.

#Remarks

Handle the Validate event to manually validate the editor (e.g. to limit the range of valid values, implement a custom conditional validation mechanism, etc).

To specify when the editor should automatically validate its value, use the BaseEdit.ValidateOnEnterKeyPressed and BaseEdit.ValidateOnTextInput properties. To manually force the editor's validation, call the BaseEdit.DoValidate method.

NOTE

The Validate event is not raised if the editor's BaseEdit.CausesValidation property is set to false.

To learn more, see Input Validation.

#Examples

The following example shows how to handle the BaseEdit.Validate event to provide a custom validation procedure.

The image below shows the result:

exDataValidation

private void agTextEdit_Validate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e) {
    if (e.Value == null) return;
    if (e.Value.ToString().Length > 4) return;
    e.IsValid = false;
    e.ErrorType = DevExpress.Xpf.Editors.Internal.ErrorType.Information;
    e.ErrorContent = "User ID is less than five symbols. Please correct.";
}
See Also