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

TableView.InitNewRow Event

Allows you to initialize a new row with default values.

Namespace: DevExpress.Xpf.Grid

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


public event InitNewRowEventHandler InitNewRow

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.

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.


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:TableView Name="view" NewItemRowPosition="Top" InitNewRow="InitNewRow" />
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