A newer version of this page is available. Switch to the current version.

GridViewBase.AddingNewRow Event

Occurs before adding a new row to a data grid and allows you to initialize the new record.

Namespace: DevExpress.Xpf.Grid

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

Declaration

public event AddingNewEventHandler AddingNewRow
Public Event AddingNewRow As AddingNewEventHandler

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

The AddingNewRow event fires when a new row is added to a grid using any of the control means. To initialize a new row, assign the initialized record to event arguments' NewObject property.

NOTE

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

The code sample below demonstrates how to initialize cells displayed within the New Item Row with default values:

<dxg:GridControl Name="grid">
    <dxg:GridControl.View>
        <dxg:TableView Name="view" NewItemRowPosition="Top" AddingNewRow="AddingNewRow" />
    </dxg:GridControl.View>
</dxg:GridControl>
void view_AddingNewRow(object sender, System.ComponentModel.AddingNewEventArgs e) {
    e.NewObject = new Person(1);
}

Refer to the New Item Row topic to learn more.

See Also