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
close icon

Text Paste and Read only cells

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

1 Reply

AD Administrator Syncfusion Team May 19, 2004 06:20 AM UTC

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;

Live Chat Icon For mobile
Up arrow icon