Hi Detlef,
We appreciate your interest in Syncfusion products.
This can be done by setting the values in the RowEnter event and also by handling RowEditing and RowLeave events of GridDataBoundGrid Control.
Below is the code snippet:
private void gridDataBoundGrid1_RowEnter(object sender, Syncfusion.Windows.Forms.Grid.GridRowEventArgs e)
{
if (e.RowIndex == this.gridDataBoundGrid1.Model.RowCount)
{
this.gridDataBoundGrid1.CurrentCell.BeginEdit(true);
for (int i = 0; i < dt.Columns.Count; i++)
{
this.gridDataBoundGrid1.Model.ColStyles[i + 1].Text = (string)dt.Columns[i].DefaultValue;
}
}
}
private void gridDataBoundGrid1_RowEditing(object sender, Syncfusion.Windows.Forms.Grid.GridRowEventArgs e)
{
if (this.gridDataBoundGrid1.Binder.IsAppendRow)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
this.gridDataBoundGrid1.Model.ColStyles[i + 1].Text = "";
}
}
}
private void gridDataBoundGrid1_RowLeave(object sender, Syncfusion.Windows.Forms.Grid.GridRowEventArgs e)
{
if (this.gridDataBoundGrid1.Binder.IsAppendRow)
{
for (int i = 0; i < dt.Columns.Count; i++)
{
this.gridDataBoundGrid1.Model.ColStyles[i + 1].Text = "";
}
}
}
The grid gets these default values from the Model.ColStyles[col].Text property. The idea is to conditionally set these value only when you enter the append row, and to reset them to blank when you start to edit the append row or when you leave the append row. If you set them earlier, or leave them set, then the append row will alway show the defaults (and never be blank).
You can get the sample here:
'>http://websamples.syncfusion.com/samples/Grid.Windows/Grid_WF_GDBGDefaultvalues/main.htm"> http://websamples.syncfusion.com/samples/Grid.Windows/Grid_WF_GDBGDefaultvalues/main.htmPlease let me know if this helps.
Regards,
Jisha