TableView.InitNewRow Event

Allows you to initialize a new row with default values.

Namespace: DevExpress.Xpf.Grid

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

Declaration

public event InitNewRowEventHandler InitNewRow
Public Event InitNewRow As InitNewRowEventHandler

Event Data

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

Property Description
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.
RowHandle Gets the handle of the added row.
Source Gets or sets a reference to the object that raised the event. Inherited from RoutedEventArgs.

Remarks

When an end user starts to edit the New Item Row, the InitNewRow event is raised. You can handle this event to initialize the required fields within the new record. For example, you can assign a unique value to the key field and/or assign default field values. To do this, use the GridControl.SetCellValue method.

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" InitNewRow="InitNewRow" />
    </dxg:GridControl.View>
</dxg:GridControl>
void InitNewRow(object sender, InitNewRowEventArgs e) {
    grid.SetCellValue(e.RowHandle, "UnitPrice", 10);
    grid.SetCellValue(e.RowHandle, "CompanyName", "New Company");
    grid.SetCellValue(e.RowHandle, "Discontinued", false);
}

Refer to the How to: Initialize the New Item Row with Default Values example for more information.

See Also