Skip to main content
All docs
V23.2

TreeListView.NodeEditStartingCommand Property

Gets or sets a command that is executed when a user starts to edit a node.

Namespace: DevExpress.Xpf.Grid

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

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public ICommand<NodeEditStartingArgs> NodeEditStartingCommand { get; set; }

Property Value

Type Description
ICommand<NodeEditStartingArgs>

A command that is executed when a user starts to edit a node.

Remarks

Bind a command to the NodeEditStartingCommand property to maintain a clean MVVM pattern. The command works like a NodeEditStarting event handler and allows you to process the node edit operation in a View Model.

Set the Cancel property to true to suppress the node edit operation. The moment when the bound command is executed depends on the GridControl‘s edit mode.

Edit Form

If you process data edit operations in the Edit Form, the command is executed when a user opens the form.

The NodeEditStartingArgs 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 rows.

[Command]
public void OnNodeEditStarting(NodeEditStartingArgs args) {
    if(args.IsNewItem) {
        args.CellEditors[0].Value = Employees.Count + 1;
        args.CellEditors[4].ReadOnly = true;

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

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

In-place Editors and Edit Entire Row

The command bound to the NodeEditStartingCommand property is executed 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