ClipBoardCopy in KeyDown Event

Posted by: rainriku on 8 September 2017, 3:22 pm EST

  • Posted 8 September 2017, 3:22 pm EST

    Hi experts,

    I tried to use the ClipboardCopy with ClipBoardOptions.AsStringSkipHidden in the Keydown event when
    Ctrl+C is pressed. but when i tried to paste it, it still gets the hidden cell data, I'd like to disable the default ctrl+c is there any way i can do this?

    Thank you


  • Replied 8 September 2017, 3:22 pm EST

    Hello,

    Here is the complete code used for the same wherein you need to disable AutoClipboard and then write your own copy paste code on keydown event as given below:-


    private void Form1_Load(object sender, EventArgs e)
    {
    fpSpread1_Sheet1.Cells[1, 1].Text = "B";
    fpSpread1_Sheet1.Cells[1, 2].Text = "C";
    fpSpread1_Sheet1.Cells[1, 3].Text = "D";
    fpSpread1_Sheet1.Cells[1, 4].Text = "E";

    fpSpread1_Sheet1.Columns[2].Visible = false;
    fpSpread1_Sheet1.Columns[3].Visible = false;
    fpSpread1.AutoClipboard = false;

    fpSpread1.KeyDown += fpSpread1_KeyDown;
    }

    void fpSpread1_KeyDown(object sender, KeyEventArgs e)
    {
    if (e.Control && e.KeyCode == Keys.C)
    {
    fpSpread1_Sheet1.ClipboardCopy(FarPoint.Win.Spread.ClipboardCopyOptions.AsStringSkipHidden);
    }
    if (e.Control && e.KeyCode == Keys.V)
    {
    fpSpread1_Sheet1.ClipboardPaste(FarPoint.Win.Spread.ClipboardPasteOptions.AsStringSkipHidden);
    }
    }


    Hope it helps.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:22 pm EST

    fpSpread1.AutoClipboard = false;

    Is this the one I lack. Now its okay..
    Thank you for your reply..
  • Replied 8 September 2017, 3:23 pm EST

    deleted
  • Replied 8 September 2017, 3:23 pm EST

    Hello,

    Unfortunately, we haven't heard back from our developers yet. We have asked for an urgent update on the same at high priority.

    We will update you once we hear anything from them.

    We regret the inconvenience.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:23 pm EST

    Any updates? on this one?..
  • Marked as Answer

    Replied 8 September 2017, 3:23 pm EST

    Hi,

    If you copy a cell value which contains an embedded double-quote character, and the cell is not in edit mode, then Spread will automatically wrap the contents of that cell with double-quotes, and insert an additional double-quote after the embedded one inside the string. On pasting, if the value on the clipboard is wrapped inside double-quotes, then the paste logic should remove the extra double-quote inserted (convert all instances of two consecutive double-quote characters into one) and strip off the double-quotes around the value (at the start and end).

    Excel works the same way -- if you type a value containing a double-quote in a cell and copy/paste it to Notepad (not in edit mode), then you should see the raw value pasted in Notepad as Excel puts it on the clipboard, exactly like Spread -- resulting in "3""" in this case, like in your picture. But if you paste that value into Excel (or into Spread), not in edit mode, then it should paste the value as just 3" (as it appears in the source cell).

    If you need to use Clipboard.GetText(), then you will need to handle this parsing logic in your code before setting the text to the cell.

    Regards,
    -Sean
  • Replied 8 September 2017, 3:23 pm EST

    I have an issue with the ClipboardCopy.. when i copy 3" it will paste "3""". It think its because of the double qoute..I'm not sure if we have the same behavior. Please advise..

    by the way i used Clipboard.GetText() instead of ClipboardPaste because there are some cells i need to update while pasting.

  • Replied 8 September 2017, 3:23 pm EST

    Hello,

    We are able to replicate the issue and hence we are escalating the same to the concerned team for the fix.

    Tracking id for your issue is #151490

    We will update you once we hear anything from them.

    Thanks,
    Reeva
  • Replied 8 September 2017, 3:23 pm EST

    Hi,

    Any updates on this issue?
  • Replied 8 September 2017, 3:23 pm EST

    I cannot replicate on what you say that Excel works the same way. My excel version is 2010

    I limit my test on just copying on a cell not on edit mode and i used the default spread and excel 2010
    When i copy a cell with Double quote from EXCEL to notepad or SPREAD, the value will be correct.
    when i copy a cell with Double quote from SPREAD and paste it to EXCEL , the value will be correct.
    when i copy a cell with Double quote from SPREAD and paste it to SPREAD or Notepad value will have an additional double quotes.

    Anyways, I already handled the pasting logic in spread in our program but in the default spread itself you may like to check it first.

    Thanks






Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels