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.

cell addresses in GridControl copy / past

Thread ID:

Created:

Updated:

Platform:

Replies:

94721 May 29,2010 09:42 AM Jun 1,2010 07:44 AM Windows Forms 4
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On May 29, 2010 09:42 AM

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 02:14 AM

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:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=FormulaRef1934678298.zip

Let me know if you have any queries.

Regards,
Nirmal

Administrator [Syncfusion]
Replied On May 31, 2010 08:07 AM

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

"=Sum(A1:B1)"

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

"=Sum(A2:B2)"

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.

-Jan-

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

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?

v/r
Jan

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

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);
gridControl1.CutPaste.Paste();
}


Also please refer the sample below:
http://www.syncfusion.com/uploads/redirect.aspx?&team=support&file=FormulaRef-126027284.zip

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.

Regards,
Nirmal

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.

;