ColumnView.InitNewRow Event
Enables you to initialize added rows.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v18.1.dll
Declaration
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
You can handle the InitNewRow event to initialize newly added rows. To initialize row cells call the ColumnView.SetRowCellValue method. Use the event’s RowHandle parameter as the row identifier, required by the ColumnView.SetRowCellValue method.
The InitNewRow event is raised when a new row is added to a View. This occurs in the following cases:
- when the ColumnView.AddNewRow method is called in code;
- when the Append button of the data navigator is clicked by end-users.
- when an end-user starts typing text in the New Item Row.
Note that some values within the new row may be initialized automatically (depending upon the data source). For example, the key field value may already be assigned. Cells that are not initialized automatically will be displayed as empty.
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);
}
Related GitHub Examples
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.