TreeViewControl.ValidateNode Event
Allows you to validate the focused node’s data and specify whether to close the node’s editor.
Namespace: DevExpress.Xpf.Grid
Assembly: DevExpress.Xpf.Grid.v24.1.dll
NuGet Package: DevExpress.Wpf.Grid.Core
Declaration
Event Data
The ValidateNode event's data class is TreeViewNodeValidationEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Culture | Gets the culture related to the validation. Inherited from ValidationEventArgs. |
ErrorContent | Gets or sets an object that describes the validation error. Inherited from ValidationEventArgs. |
ErrorType | Gets or sets the error icon type. Inherited from ValidationEventArgs. |
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. Inherited from ValidationEventArgs. |
Node | Gets the processed node. |
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. |
RowHandle | Gets the processed node’s row handle. |
Source | Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs. |
TreeViewControl | Gets the TreeViewControl that raised this event. |
UpdateSource | Gets the action that caused the validation. Inherited from ValidationEventArgs. |
Value | Gets the editor’s value. Inherited from ValidationEventArgs. |
The event data class exposes the following methods:
Method | Description |
---|---|
InvokeEventHandler(Delegate, Object) | When overridden in a derived class, provides a way to invoke event handlers in a type-specific way, which can increase efficiency over the base implementation. Inherited from RoutedEventArgs. |
OnSetSource(Object) | When overridden in a derived class, provides a notification callback entry point whenever the value of the Source property of an instance changes. Inherited from RoutedEventArgs. |
SetError(Object, ErrorType) | Marks the processed input value as invalid and displays an error within the editor with the specified error icon type. Inherited from ValidationEventArgs. |
SetError(Object) | Marks the processed input value as invalid and displays an error within the editor. Inherited from ValidationEventArgs. |
Remarks
The TreeViewControl allows you to validate new node values. To enable this behavior, handle the ValidateNode event. This event occurs when a node is about to lose focus.
The Value property returns the focused node’s new value. To indicate that the new value is invalid, set the IsValid property to false.
Set the AllowLeaveInvalidEditor property to true to allow users to close an editor that did not pass validation.
Example
<dxg:TreeViewControl x:Name="treeview"
AllowEditing="True"
ValidateNode="treeview_ValidateNode"
... />
void treeview_ValidateNode(object sender, DevExpress.Xpf.Grid.TreeList.TreeViewNodeValidationEventArgs e) {
e.IsValid = (e.Value != null) && (e.Value.ToString().Length >= 5);
e.ErrorType = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Warning;
e.ErrorContent = "The name must contain at least 5 characters.";
}
For more information, refer to the following help topic: Edit Data.