By default a context menu appears when the C1PreviewPane is right-clicked at run time. This ContextMenuStrip includes settings for manipulating the preview including items from the File, Zoom, and Text toobars. You can create your own context menu by adding a ContextMenuStrip control and assigning it to the PreviewPane.ContextMenuStrip property. You can also customize the existing ContextMenuStrip by adding additional items or removing existing items.
The following example removes the standard "Copy" item from the context menu. Complete the following steps:
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
AddHandler PreviewPane.ContextMenuStrip.Opening, AddressOf ContextMenuStrip_Opening |
To write code in C#
C# |
Copy Code
|
---|---|
PreviewPane.ContextMenuStrip.Opening += new CancelEventHandler(ContextMenuStrip_Opening); |
To write code in Visual Basic
Visual Basic |
Copy Code
|
---|---|
Private Sub ContextMenuStrip_Opening(ByVal sender As Object, ByVal e As CancelEventArgs) Dim cms As System.Windows.Forms.ContextMenuStrip = DirectCast(sender, System.Windows.Forms.ContextMenuStrip) For Each item As ToolStripItem In cms.Items If item.Tag = ContextMenuTags.Copy Then item.Visible = False End If Next End Sub |
To write code in C#
C# |
Copy Code
|
---|---|
void ContextMenuStrip_Opening(object sender, CancelEventArgs e) { System.Windows.Forms.ContextMenuStrip cms = (System.Windows.Forms.ContextMenuStrip)sender; foreach (ToolStripItem item in cms.Items) if (item.Tag == ContextMenuTags.Copy) item.Visible = false; } |
When you right-click the preview pane in the C1PrintPreviewControl control, observe that the standard "Copy" item is not included on the context menu.