wpf-devexpress-dot-xpf-dot-grid-dot-tableview-144d9c33.md
Gets or sets a command that is executed when a user starts to edit a row.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public ICommand<RowEditStartingArgs> RowEditStartingCommand { get; set; }
Public Property RowEditStartingCommand As ICommand(Of RowEditStartingArgs)
| Type | Description |
|---|---|
| ICommand<RowEditStartingArgs> |
A command that is executed when a user starts to edit a row.
|
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.
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;
}
}
Public Sub OnRowEditStarting(ByVal args As RowEditStartingArgs)
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 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.
wpf-data-grid-edit-form-related-cells/CS/SynchronizeEditValuesInEditForm_MVVM/MainWindow.xaml#L22
<dxg:GridControl.View>
<dxg:TableView EditFormShowMode="Inline" CellValueChangingCommand="{Binding SynchronizeValuesCommand}" RowEditStartingCommand="{Binding InitializeEditingCommand}" />
</dxg:GridControl.View>
wpf-data-grid-specify-edit-form-settings/CS/DefineEditFormSettings_MVVM/MainWindow.xaml#L17
<dxg:TableView EditFormShowMode="InlineHideRow"
NewItemRowPosition="Top" RowEditStartingCommand="{Binding OnRowEditStartingCommand}"/>
</dxg:GridControl.View>
See Also