windowsforms-devexpress-dot-xtraverticalgrid-dot-vgridcontrolbase-2537e6ec.md
Enables added records to be initialized.
Namespace : DevExpress.XtraVerticalGrid
Assembly : DevExpress.XtraVerticalGrid.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.VerticalGrid
public event RecordIndexEventHandler InitNewRecord
Public Event InitNewRecord As RecordIndexEventHandler
The InitNewRecord event's data class is DevExpress.XtraVerticalGrid.Events.RecordIndexEventArgs.
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.
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);
}
Imports DevExpress.XtraVerticalGrid
Imports DevExpress.XtraVerticalGrid.Events
VGridControl1.AddNewRecord()
' ...
Private Sub VGridControl1_InitNewRecord(ByVal sender As Object, _
ByVal e As RecordIndexEventArgs) Handles VGridControl1.InitNewRecord
Dim vGrid As Vertical Grid Control = sender
vGrid.SetCellValue(vGrid.Rows.GetRowByFieldName("ID", True), _
e.RecordIndex, vGrid.RecordCount)
End Sub
See Also