Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

VGridControlBase.InitNewRecord Event

Enables added records to be initialized.

Namespace: DevExpress.XtraVerticalGrid

Assembly: DevExpress.XtraVerticalGrid.v24.2.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid

#Declaration

public event RecordIndexEventHandler InitNewRecord

#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.

#Example

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