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.

GridGroupingControl and AddNewRecord Behavior

Thread ID:

Created:

Updated:

Platform:

Replies:

51974 Nov 17,2006 02:05 PM Nov 24,2006 05:10 AM Windows Forms 2
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On November 17, 2006 02:05 PM

Good afternoon. I am having some difficulty properly implementing "AddNewRecord" functionality with a GridGroupingControl. I am binding to a custom object collection, and the underlying data in the grid can be manipulated either through the AddNewRecord (empty record on the grid) or through a set of "Add/Remove" buttons.

What is the proper code that should be implemented in my "Add" and "Delete" methods which correspond to the button events? When the "AddNewRecord" behavior is disabled, the add/delete functions as expected. However, when "AddNewRecord" is enabled, the grid works as expected at the start, but fails to function properly after manipulating the collection through the "AddNewRecord" row and the buttons. It seems that there may be issues with the CurrencyManager staying in sync with the underlying grid, but I cannot be certain.

The error message I receive when the problems begin is something along the lines of:

SaveRecord: must be between 0 and 0
Parameter name: index
Actual value was 1.

By refreshing the grid, the behavior sometimes returns to normal, but not always. When this message appears, the only record in the grid which is visible is the "AddNewRecord" row. When entering data into the cells of the "AddNewRecord" row, the prompt is displayed and upon clicking "OK", my newly entered data disappears. A refresh of the grid will reveal that the data was actually persisted to the colleciton, but the grid was simply out of sync.

What is the proper sequence of events and actions that should be taken in terms of databinding, currency manager refreshes, collection modifications, etc.? I can post the code that I currently have, if that would be helpful in identifying a solution.

Thanks for any help you can provide.

Administrator [Syncfusion]
Replied On November 21, 2006 11:54 AM

Additional information regarding this post.

Due to the inclusion of the "Add New Record" functionality, an event is raised when the new record is added to the grid through the "Add New Record" functionality: the SourceListRecordChanged event. When this event is fired (and subsequently handled by my code), the grid continues to behave properly. There are times however, when the SourceListRecordChanged event is not fired, and this is when the grid begins to get problematic. Ordinariarly, the grid will execute the SourceListRecordChanged event when the grid loses focus (and thus persist the pending "new row" to the underlying collection), but after modifying the underlying data source, the event sometimes does not fire.

What would prevent the SourceListRecordChanged event from firing? Is there a method on the grid which will "commit" pending changes and ultimately invoke the SourceListRecordChanged event?

Thanks for any information you can provide.

Administrator [Syncfusion]
Replied On November 24, 2006 05:10 AM

Hi John,

If you want to actually add new items to the custom object collection through the GridGroupingControl, then you should also have your custom object collection implement IBindingList to support the addnew functionality directly from the grid.

Please refer the StrongTypedCollection browser sample for more details.
\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Grouping.Windows\Samples\StrongTypedCollection\

This will avoid the errors you are seeing.

Best Regards,
Haneef

CONFIRMATION

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.

;