This example handles the InitNewRow event to initialize the New Item Row with default values. The GridView raises the InitNewRow
event after the user has changed the value of a cell. The example also handles the GridView.ShownEditor event to force the InitNewRow
event to fire after the user has clicked the "Item New Row" cell:
private void gridView1_InitNewRow(object sender, DevExpress.XtraGrid.Views.Grid.InitNewRowEventArgs e) {
GridView view = sender as GridView;
view.SetRowCellValue(e.RowHandle, view.Columns["Name"], "Noname");
view.SetRowCellValue(e.RowHandle, view.Columns["Date"], DateTime.Today);
}
private void gridView1_ShownEditor(object sender, EventArgs e) {
GridView view = sender as GridView;
if (view.IsNewItemRow(view.FocusedRowHandle) && view.FocusedColumn.FieldName != "ID")
view.ActiveEditor.IsModified = true;
}
(you will be redirected to DevExpress.com to submit your response)