Disable or modify context menu on C1PrintPreviewControl preview pane

Posted by: jong on 19 June 2018, 3:19 pm EST

    • Post Options:
    • Link

    Posted 19 June 2018, 3:19 pm EST

    Is there any way to disable or modify items on the right-click context menu on the preview pane of the C1PrintPreviewControl? I am using the C1PrintPreview control on a background worker thread, and if the user clicks the “Copy” item on the context menu, the user receives an error because the thread is not a single threaded apartment thread. Consequently, I need to either disable or trap the Copy command. Can this be done?

    Thanks.

    Jon

  • Posted 20 June 2018, 2:01 am EST

    Hello Jon,

    Please try using the below mentioned code snippet for your scenario and let us know if it works:

    C1PrintPreviewControl1.PreviewPane.ContextMenuStrip.Items("Copy").Enabled = False
    
    

    Ensure that you set this property in the ContextMenuStrip.Opening event.

    If the issue persists, share your sample application so that we can observe the issue and assist you accordingly.

    Thanks,

    Esha

  • Posted 20 June 2018, 9:39 am EST

    Thanks for the suggestion. Unfortunately, using the code you provided caused a “Object reference not set to an instance of an object” exception. Looking at the context menu items in debug, it would appear that none of the items have a non-empty key. Consequently, an item with the key or name “Copy” did not exist in the collection. I did get it to work with the following code in the ContextMenu.Opening event:

          
    Dim cnt as integer =  previewControl.PreviewPane.ContextMenuStrip.Items.Count - 1
    For i As Integer = 0 To cnt 
         Dim t As ToolStripItem = previewControl.PreviewPane.ContextMenuStrip.Items(i)
         If t.Text = "Copy" Then
              t.Enabled = False
              Exit For
         End If
     Next i
    
    
  • Posted 20 June 2018, 11:30 pm EST

    Thanks, Jon.

    Your solution will help the other users as well.

    ~Esha

Need extra support?

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

Learn More

Forum Channels