BaseEdit.Validate Event
Enables you to validate the editor's value.
Namespace: DevExpress.Xpf.Editors
Assembly: DevExpress.Xpf.Core.v14.2.dll
#Declaration
#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. |
Error |
Gets or sets an object that describes the validation error. |
Error |
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 Routed |
Is |
Gets or sets a value specifying whether the value is valid. |
Original |
Gets the original reporting source as determined by pure hit testing, before any possible Source adjustment by a parent class.
Inherited from Routed |
Routed |
Gets or sets the Routed |
Source |
Gets or sets a reference to the object that raised the event.
Inherited from Routed |
Update |
Gets an object that invoked the Base |
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 Base
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:
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.";
}