VGridControlBase.InitNewRecord Event

Enables added records to be initialized.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v20.1.dll

Declaration

public event RecordIndexEventHandler InitNewRecord
Public Event InitNewRecord As RecordIndexEventHandler

Event Data

The InitNewRecord event's data class is DevExpress.XtraVerticalGrid.Events.RecordIndexEventArgs.

Remarks

The InitNewRecord event is raised when a new record is added to the vertical grid. A new record can be added using the grid's VGridControlBase.AddNewRecord method. End-users can do this using the Append button of the data navigator which is bound to the same data source as the vertical grid.

The cells within the new record can automatically be initialized (depending upon the data source). For instance, the key field value may already be assigned. Cells that are not initialized automatically will be displayed as empty. Handle the InitNewRecord event to manually initialize such cells.

The new record is identified by the event parameter's RecordIndex property.

Examples

The following code shows how to initialize the "ID" field of a new record via the VGridControlBase.InitNewRecord event.

using DevExpress.XtraVerticalGrid;
using DevExpress.XtraVerticalGrid.Events;

vGridControl1.AddNewRecord();
// ...
private void vGridControl1_InitNewRecord(object sender, RecordIndexEventArgs e) {
   Vertical Grid Control vGrid = sender as VGridControl;
   vGrid.SetCellValue(vGrid.Rows.GetRowByFieldName("ID", true), 
     e.RecordIndex, vGrid.RecordCount);
}
See Also