GridViewBase.AddingNewRow Event

Occurs when a new row is added to the GridControl.

Namespace: DevExpress.Xpf.Grid

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

Declaration

public event AddingNewEventHandler AddingNewRow

Event Data

The AddingNewRow event's data class is AddingNewEventArgs. The following properties provide information specific to this event:

Property Description
NewObject Gets or sets the object to be added to the binding list.

Remarks

Handle the AddingNewRow event as follows:

<dxg:GridControl>
    <dxg:GridControl.View>
        <dxg:TableView NewItemRowPosition="Top" AddingNewRow="view_AddingNewRow" />
    </dxg:GridControl.View>
</dxg:GridControl>

Assign a data record to the AddingNewEventArgs.NewObject property to initialize a row:

void view_AddingNewRow(object sender, System.ComponentModel.AddingNewEventArgs e) {
    e.NewObject = new Person(1);
}

Note

The AddingNewRow event does not fire when you add a new row directly to a bound data source.

Refer to the following topic for information on how to add a new row to the GridControl: New Item Row.

If you want to maintain a clean MVVM pattern and process the row add operation in a View Model, create a command and bind it to the AddingNewRowCommand property.

See Also