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

ColumnView.InitNewRow Event

Enables you to initialize added rows.

Namespace: DevExpress.XtraGrid.Views.Base

Assembly: DevExpress.XtraGrid.v19.2.dll

Declaration

[DXCategory("Data")]
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
RowHandle Gets the handle of the added row.

Remarks

The InitNewRow event raises when a new row is added to a View. This occurs in the following cases:

When this happens, you can handle the InitNewRow event to fill a newly added row (or some of its cells) with initial values. To do that, read the event’s RowHandle value and pass it to the ColumnView.SetRowCellValue method as a parameter (see the example below).

Note that some values within a new row can be automatically initialized by a data source. For example, the key field value may already be assigned.

Note

Do not call the ColumnView.UpdateCurrentRow and ColumnView.CancelUpdateCurrentRow methods from your InitNewRow event handler.

Online Video

WinForms Grid: Initialize New Rows.

Example

The following code shows how to initialize the “PurchaseDate” field of a new row via the ColumnView.InitNewRow event.

using DevExpress.XtraGrid.Views.Grid;

private void gridView1_InitNewRow(object sender, InitNewRowEventArgs e) {
   GridView view = sender as GridView;
   view.SetRowCellValue(e.RowHandle, view.Columns["PurchaseDate"], DateTime.Today);
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference 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