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.
Syncfusion Feedback

Adding/Removing Rows from a Virtual Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

9004 Dec 2,2003 12:27 PM UTC Dec 4,2003 12:14 PM UTC Windows Forms 5
loading
Tags: GridControl
Jason Thompson
Asked On December 2, 2003 12:27 PM UTC

I am attempting to programmatically add and remove rows from a Virtual Grid. Incrementing the RowCount property of the GridControl does not work. Similarly, decrementing the RowCount property of the GridControl does not work either. The main reason for doing this programmatically is to take advantage of the undo/redo functionality of the grid when adding/removing rows. Jason

Administrator [Syncfusion]
Replied On December 2, 2003 04:00 PM UTC

In a virtual grid, you will have to manage adding and removing rows from your external datasource. The virtual grid just displays the data in your datasource. So, if you want a row removed, you have to remove it from the datasource. Normally, in a virtual grid, you do not explicitly set grid.RowCount = xxxx. Instead, you use the grid.QueryRowCount event and dynamically provide the row by setting e.Size and e.Handled, based on e.Index that comes in. Normally, you would set e.Size directly from the external data source in some manner. If you do this, then if you add a row to your external data or remove a row from the external data, the grid will automatically know the proper row count. (You may have to call grid.Refresh after you modify the row count in your external data source, but that should be it). When the grid is drawn the next time, it should reflect the changed data.

Jason Thompson
Replied On December 3, 2003 11:20 AM UTC

I had tried what you suggested (modifying the source data and calling refresh), but it doesn''t assist me in accomplishing my goal. It would be nice to be able to programmatically add or remove a row within a virtual grid that also was placed on the commandstack. The Undo/Redo functionality is a necessity.

Administrator [Syncfusion]
Replied On December 3, 2003 12:53 PM UTC

You would have to create Custom Undo commands that have actually have everything needed to undo and redo the actions you want to handle. So, if you want to undo adding/removing a row from your data source, you would derive from GridModelCommand. In your derived class, you would add whatever properties/structures you need to be able to undo and redo this add/remove action. Then you would also override the Execute method to actually perform the undo action. If you have the source code, you can see how the grid does this type of thing. Do a search on GridModelSetCoveredRangesCommand for example. This will show you how the class is implemented, and then how an instance of it is added to the CommandStack when covered cells are set. If you search for GridModelCommand in the source code, you will see all the undo actions supported as their commands all derive from GridModelCommand.

Jason Thompson
Replied On December 4, 2003 11:42 AM UTC

Would it be possible for me to fake a GridModelInsertRangeCommand and a GridModelRemoveRangeCommand for my Remove/Add operations? You would think that it would be possible; however, the documentation provided for those class is extrememly sparse. Jason

Jason Thompson
Replied On December 4, 2003 12:14 PM UTC

Nevermind. Those commands are apparently only applicable to Bound Grids. Jason

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.

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

;