wpf-devexpress-dot-xpf-dot-grid-dot-treelistview-3a4f9449.md
Gets or sets a command that is executed when a user starts to edit a node.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public ICommand<NodeEditStartingArgs> NodeEditStartingCommand { get; set; }
Public Property NodeEditStartingCommand As ICommand(Of NodeEditStartingArgs)
| Type | Description |
|---|---|
| ICommand<NodeEditStartingArgs> |
A command that is executed when a user starts to edit a node.
|
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.
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;
}
}
<Command>
Public Sub OnNodeEditStarting(ByVal args As NodeEditStartingArgs)
If args.IsNewItem Then
args.CellEditors(0).Value = Employees.Count + 1
args.CellEditors(4).[ReadOnly] = True
Else
args.CellEditors(0).[ReadOnly] = True
args.CellEditors(4).[ReadOnly] = False
End If
End Sub
View Example: Data Grid for WPF - How to Specify Edit Form Settings
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