Bookmark.BeforeRightClick Event

Definition

Occurs when a Bookmark control is right-clicked, before the default right-click action.

public:
 event Microsoft::Office::Tools::Word::ClickEventHandler ^ BeforeRightClick;
event Microsoft.Office.Tools.Word.ClickEventHandler BeforeRightClick;
member this.BeforeRightClick : Microsoft.Office.Tools.Word.ClickEventHandler 
Event BeforeRightClick As ClickEventHandler 

Event Type

Examples

The following code example adds a Bookmark control to the document and then creates a BeforeRightClick event handler. When the Bookmark control is right-clicked, the text within the bookmark is copied to the Clipboard.

This example is for a document-level customization.

Microsoft.Office.Tools.Word.Bookmark bookmark3;

private void BookmarkBeforeRightClick()
{
    this.Paragraphs[1].Range.InsertParagraphBefore();
    bookmark3 = this.Controls.AddBookmark(this.Paragraphs[1]
        .Range, "bookmark3");
    bookmark3.Text = "This is a sample bookmark.";
    bookmark3.BeforeRightClick += new Microsoft.Office.Tools
        .Word.ClickEventHandler(bookmark3_BeforeRightClick);
}

void bookmark3_BeforeRightClick(object sender, 
    Microsoft.Office.Tools.Word.ClickEventArgs e)
{
    bookmark3.Copy();
    e.Cancel = true;
}
WithEvents Bookmark3 As Microsoft.Office.Tools.Word.Bookmark

Private Sub BookmarkBeforeRightClick()
    Me.Paragraphs(1).Range.InsertParagraphBefore()
    Bookmark3 = Me.Controls.AddBookmark(Me.Paragraphs(1).Range, "Bookmark3")
    Bookmark3.Text = "This is a sample bookmark."
End Sub

Private Sub Bookmark3_BeforeRightClick(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ClickEventArgs) _
    Handles Bookmark3.BeforeRightClick
    Bookmark3.Copy()
    e.Cancel = True
End Sub

Remarks

Right-clicking overlapping Bookmark controls raises the event on each of the bookmarks that overlap.

Applies to