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

Cut/Copy/Paste Text only

Is there a way to get the Cut/Copy to only do text and ignore the style info? It seems like the grid spends a lot of time getting the style info. (For some background, I''m using a virtual grid which calculates the style for the cell based on information contained elsewhere. When I do a cut/paste I only want the text to be copied.)

4 Replies

AD Administrator Syncfusion Team August 19, 2004 05:24 PM UTC

You can turn off the Styles flag in the ClipboardFlags property. this.gridControl1.Model.CutPaste.ClipboardFlags &= ~GridDragDropFlags.Styles;

ED Eric Duesing August 20, 2004 09:08 AM UTC

That didn''t work. In fact, that slows down the Cut() call TREMENDOUSLY. And QueryCellInfo() is still being called multiple times with RowIndex or ColIndex = -1. I wouldn''t think that would happen if you are doing a text only copy? Attached is a sample that demonstrates the problem. TestCut_5472.zip

AD Administrator Syncfusion Team August 20, 2004 11:23 AM UTC

Here is why Cutting Styles is much quicker than cutting just text. The part of our code library that you should look at is \\Grid\Src\Base\Model\GridModel.cs(6375) which is the gridModel.ClearCells method. When clearing text only, this code calls GetFormattedText and ApplyFormattedText that gives each cell the opportunity to format what it thinks an empty cell should be. For example, an empty DateTime cell may need to be different than an empty string cell or an empty MyObject cell. Calling these methods trigger multiple events, and this is what is taking the time. When cutting styles, this problem does not exist as the cell will no longer be a DateTime or any other celltype than the default celltype. So, how can you work around these methods to make things work faster in your particular situation. If you only want to cut/copy text only, then I probably would handle these tasks myself using the special knowledge of my virtual data source. I suspect you would be able to loop through your virtual datasource and put a delimited Text string on the clipboard in a fraction of the time it would take the grid to do the same thing raising QueryCellInfo events to retrieve the values. You can handle the grid.ClipboardCopy, Paste and Cut events to do such things in general. Or, in your case, you could do it directly from teh menu handler. To manage clearing the cells, you can handle the ClearingCells event. To give you an idea of the difference of time required, I modified your sample replacing the Cut with a CustomCopy that just creates a string copy and puts in on the Clipboard. The custom copy takes about a half second on my system, while the grid''s default text copy takes about 20 seconds. The difference is that I accessed the datasource directly and created the string to place on the clipboard, and the grid''s default copy goes the the QueryCellInfo event (and others maybe) to get the values. As far as QueryCellInfo being raised with e.RowIndex/e.ColIndex = -1, this is again by design. The reason is that any style setting (including possibly Text) that is not explicitly set in the cell style has the chance of being set in the row or column styles (which is what these -1 values are requesting). So, the style inheritance architecture requires the row and column styles be queried when you are retrieving a cell style. TestCut_5472_8654.zip

ED Eric Duesing August 23, 2004 09:25 AM UTC

Thanks. That''s what I suspected and what I had planned to do.

Live Chat Icon For mobile
Up arrow icon