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

TableView.RowEditStartingCommand Property

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

Namespace: DevExpress.Xpf.Grid

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

NuGet Package: DevExpress.Wpf.Grid.Core

Declaration

public ICommand<RowEditStartingArgs> RowEditStartingCommand { get; set; }

Property Value

Type Description
DevExpress.Mvvm.ICommand<RowEditStartingArgs>

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

Remarks

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

Set the Cancel property to true to suppress the row 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 RowEditStartingArgs 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 row, 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 row 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 OnRowEditStarting(RowEditStartingArgs 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 RowEditStartingCommand property is executed when a user opens an editor in a row for the first time. The View does not activate all editors, and you cannot use the CellEditors property to specify their settings.

The following code snippets (auto-collected from DevExpress Examples) contain references to the RowEditStartingCommand property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also