disable copy-paste in comboboxcelltype

Posted by: droopy5 on 8 September 2017, 1:28 pm EST

  • Posted 8 September 2017, 1:28 pm EST

    Hi


      I have a comboboxcelltype and various other cell types in my spread. I want the copy-paste(Ctrl-c,Ctrl-V) property for the comboboxcelltype to be disabled i.e even the values from combobox musnt get copied. Whereas,for text type cells and number type cells, this property must be enabled. I gave the following code in clipboardpasting event.


    if (fpSpread2.Sheets[0].GetCellType(r, c) is FarPoint.Win.Spread.CellType.ComboBoxCellType)


    {


    e.Handled = true;


    }


    else


    {


    //allow copy paste in other cells


    FarPoint.Win.Spread.InputMap im;


    im = fpSpread2.GetInputMap(FarPoint.Win.Spread.InputMapMode.WhenFocused);


    im.Put(new FarPoint.Win.Spread.Keystroke(Keys.V, Keys.Control), FarPoint.Win.Spread.SpreadActions.ClipboardPasteValues);


    }


    When I do Ctrl C - Ctrl V from a comboboxcelltype to a general celltype,nothing gets copied.It works fine.But when i do Ctrl V again in another cell,the value present in combobox cell gets copied onto this new cell.I dont want this to happen. Can u please guide me as to where am goin wrong in the code.


     


    Thanks


    Droopy

  • Replied 8 September 2017, 1:28 pm EST

    Droopy,


    You are only checking the cell you are trying to paste to make sure it is not ComboboxCellType. You should either store off the cell that is copied so you can check it in the ClipboardPasting event. Or you can get the CellInfoRange object off the clipboard in the Clipboard pasting event to ss exactly what was stored in the copy and then programatically paste what you want.

  • Replied 8 September 2017, 1:28 pm EST

    Hi Scotts,


       Am sorry. I dint get what u had explained. I get the cellrange using the below code.Now how will i check whether the user has copied from comboboxcelltype? If yes, How do i stop him from pasting the combobox value anywhere else in the spread?


    FarPoint.Win.Spread.Model.CellRange cr;


    cr = fpSpread2.GetCellFromPixel(0, 0, e.X, e.Y);

  • Replied 8 September 2017, 1:28 pm EST

    Hello,


    Take a look at the following thread for information about the CellInfoRange object and how to read this to get the celltype that is trying to be pasted in each cell.

Need extra support?

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

Learn More

Forum Channels