Cut/Paste enabled while Sheet is Read-Only!

Posted by: sarithav on 8 September 2017, 12:33 pm EST

  • Posted 8 September 2017, 12:33 pm EST

    Hi,
      I've set a sheet's OperationMode to ReadOnly, so editing is disabled, *but* I can still use Ctrl-X and Ctrl-V to cut and paste cell values, which shouldn't be the case! I would also like to disable a copy-cut-paste contextmenu I had created for the sheet, when it is in read-only mode.

    Please help.

    Thanks,
    Saritha
  • Replied 8 September 2017, 12:33 pm EST

    Siritha -

    You posted this in the WebForms section but it sounds like you are using the WindowsForms version.  Which one are you using?
  • Replied 8 September 2017, 12:33 pm EST

    Sorry, didn't realize I was in the WebForms section. Yes, I'm using the WinForms version.
    Should I post this again over there?
  • Replied 8 September 2017, 12:33 pm EST

    Are you using the 2.5.1009.2002 or 2.5.2009.2005 version?
  • Replied 8 September 2017, 12:33 pm EST

    Saritha -

    I am not able to reproduce this issue.  If I set the sheet to ReadOnly and try to copy and paste cell values nothing happens.  You can always set AutoClipboard to false to make sure.  If you are in ReadOnly mode and don't want your context menu to show up just query the OperationMode and set the ContextMenu property to Nothing.
  • Replied 8 September 2017, 12:33 pm EST

    Saritha -

    Could you post a small project reproducing this for us to debug.  I am not able to copy/paste any values when the sheet is ReadOnly with either version.
  • Replied 8 September 2017, 12:33 pm EST

    Sorry for the delay in replying, was swamped with work.

    I can't do a normal cut/paste either, but I can do it through the context menu. Is there a way to prevent the copy-cut-paste menu from appearing when the sheet is read-only?
  • Replied 8 September 2017, 12:33 pm EST

    saritha -

    Could you post a small project reproducing your issues for us to debug?  With the sheet set to read only I am not able to copy/paste nor do I get a context menu to show up.
  • Replied 8 September 2017, 12:33 pm EST

    I'm really sorry, but I don't have the time to create a small project for this issue.
    I'm copying some code from my actual project, maybe that'll help. This was a custom menu I had created.

       Private Sub LoadContextMenu()
            Dim custommenu As New ContextMenu

            custommenu.MenuItems.Add("&Cut", New EventHandler(AddressOf ContextMenu_Cut))
            custommenu.MenuItems.Add("&Copy", New EventHandler(AddressOf ContextMenu_Copy))
            custommenu.MenuItems.Add("&Paste", New EventHandler(AddressOf ContextMenu_Paste))

            grdAnalysis.ContextMenu = custommenu
        End Sub

    (where grdAnalysis is my Spread control)

    This was showing up even in read-only mode.

    But I've just figured out a way to stop it from showing up. When a sheet is readonly, I set grdAnalysis.ContextMenu = nothing. This works.

    If you have any better suggestions, please let me know..otherwise this'll do!
  • Replied 8 September 2017, 12:33 pm EST

    saritha -

    I don't know how you were able to get the context menu to show up in read only mode.  I never could, but as I suggested earlier setting the contextmenu = nothing, as you have, would be the way to go.
  • Replied 8 September 2017, 12:33 pm EST

    I have the 2002/2003 version.
Need extra support?

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

Learn More

Forum Channels