We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

EnableAddNew adds to two new rows

Hi Clay, When I try to set EnableAddNew property as True in the AddNew Button click event in my Screen, two new rows are getting added at the bottom of the Grid. User needs only one row to be added when he clicks on AddNew button... Please revert back at the Earliest.. Thanks in Advance, Thiyagu.

5 Replies

AD Administrator Syncfusion Team September 30, 2004 04:46 AM

I tried to reproduce this problem using 2.1.0.9 in the attached sample, but could not. Can you see the problem in the sample? AddNew_9770.zip


TH Thiyagu September 30, 2004 05:15 AM

But here what I''m trying to Do is I''m getting the Focus to newly Added row using the CurrentCell.Moveto Method.. Plz find the Modified sample as an Attachment Thiyagu.. >I tried to reproduce this problem using 2.1.0.9 in the attached sample, but could not. Can you see the problem in the sample?


TH Thiyagu September 30, 2004 05:17 AM

Sorry forget to attach the Sample.. Here is the Attachment.. >But here what I''m trying to Do is I''m getting the Focus to newly Added row using the CurrentCell.Moveto Method.. > >Plz find the Modified sample as an Attachment > >Thiyagu.. > > >>I tried to reproduce this problem using 2.1.0.9 in the attached sample, but could not. Can you see the problem in the sample? > AddNew_663.zip


AD Administrator Syncfusion Team September 30, 2004 05:31 AM

Starting an edit on the addnew row will automatically create the next addnew row. This is MS-Access type behavior, always showing an empty addnew row. If you do not want this, the simplest way to handle things is to just not use the EnableAddNew property, but instead add the row directly. You can do this using the CurrencyManager, or even the DataTable itself.
private void button1_Click(object sender, System.EventArgs e)
{
	this.gridDataBoundGrid1.Focus();
	CurrencyManager cm = (CurrencyManager) this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember];
	cm.AddNew();
	this.gridDataBoundGrid1.CurrentCell.MoveTo(this.gridDataBoundGrid1.Model.RowCount,1);
	this.gridDataBoundGrid1[this.gridDataBoundGrid1.Model.RowCount,4].Text = "YES";
}


TH Thiyagu September 30, 2004 06:03 AM

Thanks a lot, Clay.. Its working fine. >Starting an edit on the addnew row will automatically create the next addnew row. This is MS-Access type behavior, always showing an empty addnew row. > >If you do not want this, the simplest way to handle things is to just not use the EnableAddNew property, but instead add the row directly. You can do this using the CurrencyManager, or even the DataTable itself. > >
>private void button1_Click(object sender, System.EventArgs e)
>{
>	this.gridDataBoundGrid1.Focus();
>	CurrencyManager cm = (CurrencyManager) this.gridDataBoundGrid1.BindingContext[this.gridDataBoundGrid1.DataSource, this.gridDataBoundGrid1.DataMember];
>	cm.AddNew();
>	this.gridDataBoundGrid1.CurrentCell.MoveTo(this.gridDataBoundGrid1.Model.RowCount,1);
>	this.gridDataBoundGrid1[this.gridDataBoundGrid1.Model.RowCount,4].Text = "YES";
>}
>

Loader.
Live Chat Icon For mobile
Up arrow icon