Hi Lan,
Thanks for your interest in Syncfusion Products.
The GridGroupingControl has options to have the addnew row in top and at the bottom. If you want to have this only at the bottom, add the below property settings.
this.GridGroupingControl1.TableDescriptor.AllowNew = true;
this.GridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordBeforeDetails = false;
this.GridGroupingControl1.TopLevelGroupOptions.ShowAddNewRecordAfterDetails = true;
To add a new row programmatically in grid, you need to add a new row to the underlying datasource bound to the grid. The Grid just displays the rows from the bounded datasource.
Please try the below code. The below code gets the value for the first two columns from current record in grid and sets some default value to other columns for the new row added.
try
{
Record rec = this.gridGroupingControl1.Table.CurrentRecord;
if (rec != null)
{
object[] obj = new object[] { rec.GetValue("Col0"), rec.GetValue("Col1"), "someval", "someval", "someval" };
CurrencyManager cm = (CurrencyManager)(this.gridGroupingControl1.BindingContext[this.gridGroupingControl1.DataSource, this.gridGroupingControl1.DataMember]);
DataView dv = (DataView)cm.List;
dv.Table.Rows.Add(obj);
this.gridGroupingControl1.Engine.ResetTable();
}
}
catch (Exception ex)
{
throw ex;
}
Please let me know if this serve your needs.
Regards,
Nisha.