Skip to main content
A newer version of this page is available. .

TableView.InitNewRow Event

Allows you to initialize a new row with default values.

Namespace: DevExpress.Xpf.Grid

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

Declaration

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.

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.

The following code snippets (auto-collected from DevExpress Examples) contain references to the InitNewRow event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also