Skip to main content
All docs
V24.2

TreeListView.NodeEditStarting Event

Occurs when a user starts to edit a node.

Namespace: DevExpress.Xpf.Grid

Assembly: DevExpress.Xpf.Grid.v24.2.dll

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public event EventHandler<TreeListNodeEditStartingEventArgs> NodeEditStarting

Event Data

The NodeEditStarting event's data class is TreeListNodeEditStartingEventArgs. The following properties provide information specific to this event:

Property Description
Cancel Gets or sets whether to cancel the start of the edit operation.
CellEditors Gets an array of the CellEditorData objects that allow you to specify settings in the Edit Form.
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.
Node Gets the processed node. Inherited from TreeListNodeEventArgs.
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.
Row Gets the processed row. Inherited from TreeListNodeEventArgs.
Source Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.

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.

Remarks

Handle this event to get information about the node that the user starts to edit. If you want to maintain a clean MVVM pattern and process the start of the edit operation in a View Model, create a command and bind it to the NodeEditStartingCommand property.

Set the Cancel property to true to suppress the node edit operation. The moment when NodeEditStarting occurs depends on the GridControl‘s edit mode.

Edit Form

If you process data edit operations in the Edit Form, the event occurs when a user opens the form.

The TreeListNodeEditStartingEventArgs class contains the CellEditors property that returns an array of CellEditorData objects. Each object allows you to specify editor’s settings. When users start to edit a node, you may want to initialize values or make certain editors read-only. To do that, specify the corresponding CellEditorData.Value property or set the CellEditorData.ReadOnly property to true.

The following code sample specifies settings for the node that contains information about employees. For example, you can initialize the ID editor (CellEditors[0] in code) and disable the Department editor (CellEditors[4]) for new nodes.

private void OnNodeEditStarting(object sender, TreeListNodeEditStartingEventArgs e) {
    if (e.Node == null) { // is the New Item Row
        e.CellEditors[0].Value = grid.VisibleRowCount + 1;
        e.CellEditors[4].ReadOnly = true;

    } else {
        e.CellEditors[0].ReadOnly = true;
        e.CellEditors[4].ReadOnly = false;
    }
}

View Example: Data Grid for WPF - How to Specify Edit Form Settings

In-place Editors and Edit Entire Row

The NodeEditStarting event occurs when a user opens an editor in a node for the first time. The View does not activate all editors, and you cannot use the CellEditors property to specify their settings.

See Also