All docs
V21.2
21.2
21.1
The page you are viewing does not exist in version 21.1. This link will take you to the root page.
20.2
The page you are viewing does not exist in version 20.2. This link will take you to the root page.
20.1
The page you are viewing does not exist in version 20.1. This link will take you to the root page.
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

TableView.RowEditStarting Event

Occurs when a user starts to edit a row.

Namespace: DevExpress.Xpf.Grid

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

Declaration

public event EventHandler<RowEditStartingEventArgs> RowEditStarting

Event Data

The RowEditStarting event's data class is RowEditStartingEventArgs. 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.
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 RowEventArgs.
RowHandle Gets the processed row’s handle. Inherited from RowEventArgs.
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 row 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 RowEditStartingCommand property.

Set the Cancel property to true to suppress the row edit operation. The moment when RowEditStarting 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 RowEditStartingEventArgs 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.

private void OnRowEditStarting(object sender, RowEditStartingEventArgs e) {
    if(Equals(e.RowHandle, DataControlBase.NewItemRowHandle)) {
        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 RowEditStarting event occurs 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.

See Also