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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

cell addresses in GridControl copy / past

Thread ID:





94721 May 29,2010 01:42 PM UTC Jun 1,2010 11:44 AM UTC WinForms 4
Tags: GridControl
Administrator [Syncfusion]
Asked On May 29, 2010 01:42 PM UTC

Is there a way to implement copy & paste in a GridControl so that cell references are automatically updated. For example, if I am copying the contents of cell B2 (containing the formula: =B4+B5) to cell C2, the formula being copied would be updated during the copy to reflect the appropriate cell references (ie; after the copy, the contents of C2 would read: =C4+C5)? I have looked through the knowledge base but haven't found anything that seems to work.

Nirmal Raja [Syncfusion]
Replied On May 31, 2010 06:14 AM UTC

Hi Jan,

Thank you for your interest in Syncfusion products.

The copy and paste of a formula cell can be enabled to paste with the reference of the cell as in the Excel, by retrieving the GridFormulaEngine of the corresponding cells, and specify the copy flag to ClipBoardReferencesAdjusted and InsDelRangeReferencesUpdated.

Please refer the code below:
GridFormulaEngine engine = ((GridFormulaCellModel)this.gridControl1.CellModels["FormulaCell"]).Engine;
engine.FormulaCopyFlags |= GridFormulaCopyFlags.InsDelRangeReferencesUpdated;
engine.FormulaCopyFlags |= GridFormulaCopyFlags.ClipBoardReferencesAdjusted;

Also I have attached the sample in the below location:

Let me know if you have any queries.


Administrator [Syncfusion]
Replied On May 31, 2010 12:07 PM UTC

Thank you for the suggestion. I tried using your idea, but must have done it wrong. I took your example and added two buttons. The first copied the formula to the clipboard using

private void copyBtn_Click(object sender, EventArgs e)
Clipboard.SetText(gridControl1[1, 3].Text);

The second copied the formula back to the grid using

private void pasteBtn_Click(object sender, EventArgs e)
gridControl1[2, 3].Text = Clipboard.GetText();

After the copy, the formula had been copied correctly, but had not been updated to reflect the proper cells. It still read


What I am trying to do is have the formula be updated to read


That way I would be summing the two cells on the second row where the original formula sums the two cells on the first row.

Did I forget a step? Or is there something I'm just not understanding?

Thank you for you help.


Administrator [Syncfusion]
Replied On May 31, 2010 08:37 PM UTC

Ignore previous update. I just got it figured out. Thank you for the help. While your suggestion didn't seem to work, (I don't know why), it obviously got me looking in the right spots. Who can ask for more?


Nirmal Raja [Syncfusion]
Replied On June 1, 2010 11:44 AM UTC

Hi Jan,

Instead of using the Clipboard methods to copy and pasting cells, you can use the default copy paste from the grid object. The grid can copy the value directly from one cell and paste it to other with the help of CutPaste object.

Please refer the code below:
private void buttonAdv1_Click(object sender, EventArgs e)
gridControl1.CutPaste.CopyRange(GridRangeInfo.Cell(1, 3));

private void buttonAdv2_Click(object sender, EventArgs e)
gridControl1.CurrentCell.MoveTo(2, 3);

Also please refer the sample below:

If you see any issue as pasting the cell on invisible range, it is a known issue and fixed in the latest source and will be available in the upcoming release. Let me know what kind of query you need with regards to the issue, and we will update you with the proper solution with regards to your request.

Let me know if you have any concern.



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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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