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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Adding New Row to GridDataBoundGrid

Thread ID:





38058 Dec 5,2005 04:01 PM UTC Dec 5,2005 07:01 PM UTC WinForms 2
Tags: GridControl
Administrator [Syncfusion]
Asked On December 5, 2005 04:01 PM UTC

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 05:54 PM UTC

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 07:01 PM UTC

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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon