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.

Text Paste and Read only cells

Thread ID:





14126 May 18,2004 08:05 PM May 19,2004 02:20 AM Windows Forms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On May 18, 2004 08:05 PM

I''ve hit confusion when dealing with text pasting into a grid when one of the destination paste cells is read only. The problem is if I copy some cells from an external source (say Microsoft Excel), and paste them into a GridControl where one of the destination cells is read only, the paste only works up to that read only cell and then stops. If however, I copy some cells within the grid, and paste them over the same range the paste works ok (slightly debatable as to correctly, since the read only cell gets pasted/replaced as well). I''ve determined that it is related to the IgnoreReadOnly flag, since it works if I turned it on, but I don''t really want to ignore read only (I don''t want to paste into the read only cell), and I don''t like leaving it on all the time anyway. Is this a bug/by design, or am I getting a little over complicated? You can see the problem in the CellStyles sample. Set the style of a cell to read only, copy some cells from Excel, then try pasting such that the read only cell is in the paste destination range. Thanks, Sue

Administrator [Syncfusion]
Replied On May 19, 2004 02:20 AM

When you copy from outside the grid into the grid, the default behavior is to copy Text. This is what is happening with Excel. In this case, you can control whether ReadOnly cells get pasted, skipped or cause the operation to stop using the PasteCellText event.
private void gridControl1_PasteCellText(object sender, GridPasteCellTextEventArgs e)
		e.Cancel = true; //skip the paste on this one cell
		//e.Abort = true; //abort all further pastes
When you copy and paste from within the grid, then default behavior is to paste GridStyleInfo objects. When this is done, there is no event fired on a cell by cell basis that would allow you to easily decide whether or not to paste ReadOnly cells. One way to get around this (if you do not want to copy/paste styles) is to turn off the styles support, and then you are back in the position of only pasting text like in the first case. And you can use PasteCellText to manage the behavior of ReadOnly cells. To turn off style copy/paste support, use code like: this.gridControl1.Model.CutPaste.ClipboardFlags &= ~GridDragDropFlags.Styles;


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.