BaseEdit.Validate Event

Enables you to validate the editor's value.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v20.1.dll

Declaration

public event ValidateEventHandler Validate
Public Event Validate As ValidateEventHandler

Event Data

The Validate event's data class is ValidationEventArgs. 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 icon 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 the action that caused the validation.
Value Gets the editor's 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 implement a custom validation procedure.

The image below shows the result:

exDataValidation

<dxe:TextEdit x:Name="dxTextEdit"
          ValidateOnTextInput="False"
          Validate="dxTextEdit_Validate"/>
private void dxTextEdit_Validate(object sender, DevExpress.Xpf.Editors.ValidationEventArgs e) {
    // e.Value - the processed input value
    if (e.Value == null) return;
    if (e.Value.ToString().Length > 4) return;
    // Set the e.IsValid property to 'false' if the input value is invalid
    e.IsValid = false;
    // Specifies the error icon type
    e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Information;
    // Specifies the error text
    e.ErrorContent = "User ID is less than five symbols. Please correct.";
}
See Also