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.v20.2.dll
NuGet Packages: DevExpress.WindowsDesktop.Wpf.Grid.Core, DevExpress.Wpf.Grid.Core
Declaration
Event Data
The ValidateNode event's data class is DevExpress.Xpf.Grid.TreeList.TreeViewNodeValidationEventArgs.
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.";
}