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.v21.2.dll

NuGet Packages: DevExpress.Win.Design, DevExpress.Win.Grid

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);
}
See Also