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.

Cut/Copy/Paste Text only

Thread ID:

Created:

Updated:

Platform:

Replies:

17940 Aug 19,2004 12:52 PM Aug 23,2004 05:25 AM Windows Forms 4
loading
Tags: GridControl
Eric Duesing
Asked On August 19, 2004 12:52 PM

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.)

Administrator [Syncfusion]
Replied On August 19, 2004 01:24 PM

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

Eric Duesing
Replied On August 20, 2004 05:08 AM

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

Administrator [Syncfusion]
Replied On August 20, 2004 07:23 AM

Here is why Cutting Styles is much quicker than cutting just text. The part of our code library that you should look at is \2.1.0.9\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

Eric Duesing
Replied On August 23, 2004 05:25 AM

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

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.

;