disable copy-paste in comboboxcelltype

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

  • Posted 8 September 2017, 1:28 pm EST


      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.

    <FONT color=#0000ff size=2>

    if</FONT><FONT size=2> (fpSpread2.Sheets[0].GetCellType(r, c) </FONT><FONT color=#0000ff size=2>is</FONT><FONT size=2> FarPoint.Win.Spread.CellType.</FONT><FONT color=#2b91af size=2>ComboBoxCellType</FONT><FONT size=2>)


    e.Handled = </FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2>;


    </FONT><FONT color=#0000ff size=2>else

    </FONT><FONT size=2>


    </FONT><FONT color=#008000 size=2>//allow copy paste in other cells

    </FONT><FONT size=2>

    FarPoint.Win.Spread.</FONT><FONT color=#2b91af size=2>InputMap</FONT><FONT size=2> im;

    im = fpSpread2.GetInputMap(FarPoint.Win.Spread.</FONT><FONT color=#2b91af size=2>InputMapMode</FONT><FONT size=2>.WhenFocused);

    im.Put(</FONT><FONT color=#0000ff size=2>new</FONT><FONT size=2> FarPoint.Win.Spread.</FONT><FONT color=#2b91af size=2>Keystroke</FONT><FONT size=2>(</FONT><FONT color=#2b91af size=2>Keys</FONT><FONT size=2>.V, </FONT><FONT color=#2b91af size=2>Keys</FONT><FONT size=2>.Control), FarPoint.Win.Spread.</FONT><FONT color=#2b91af size=2>SpreadActions</FONT><FONT size=2>.ClipboardPasteValues);


    </FONT><FONT size=2>

    </FONT><FONT size=2>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.</FONT>

    <FONT size=2></FONT> 

    <FONT size=2>Thanks</FONT>

    <FONT size=2>Droopy

  • Replied 8 September 2017, 1:28 pm EST


    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?

    <FONT size=2>FarPoint.Win.Spread.Model.</FONT><FONT color=#2b91af size=2>CellRange</FONT><FONT size=2> cr;

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

  • Replied 8 September 2017, 1:28 pm EST


    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