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.
Unfortunately, activation email could not send to your email. Please try again.

Adding New Row to GridDataBoundGrid

Thread ID:





38058 Dec 5,2005 11:01 AM Dec 5,2005 02:01 PM Windows Forms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On December 5, 2005 11:01 AM

I am having a problem with my GridDataBoundGrid. One of the columns in the grid is a button. When the button is pressed a new form is launched. This new form makes modifications to the datarow from the grid. There seems to be a problem in the case where the user clicks on the button for a new row. If the user makes changes to the row, through the form, and then goes to another row in the grid, w/o directly making changes through the grid, the row disapears. To add the new row, I am doing the following: CurrencyManager cm = (CurrencyManager) this.BindingContext[grid.DataSource]; if (((e.RowIndex - 1) == cm.Count)) { grid.Binder.AddNew(); grid.Binder.SetCurrentPosition(cm.Count-1, false); } Thanks, Michael Sabin

Administrator [Syncfusion]
Replied On December 5, 2005 12:54 PM

Something to try. Instead of calling grid.Binder.AddNew, try calling cm.AddNew() (and maybe followed by cm.EndCurrentEdit()).

Administrator [Syncfusion]
Replied On December 5, 2005 02:01 PM

Thanks, that worked. The only problem was that there was a repaint issue with the grid when I did that. Here is how I got it to work nicely: if (((e.RowIndex - 1) == cm.Count)) { this.grid.BeginUpdate(); grid.Binder.AddNew(); cm.AddNew(); this.grid.Binder.SetCurrentPosition(cm.Count - 2, false); this.grid.Binder.RemoveRecords(cm.Count - 1, cm.Count -1); this.grid.EndUpdate(); }


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.