Skip to main content
A newer version of this page is available. .
All docs
V21.2

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.v21.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public event TreeViewNodeValidationEventHandler ValidateNode

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.";
}

For more information, refer to the following help topic: Edit Data.

See Also