Share via


Bookmark.BeforeRightClick Event (2007 System)

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

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
Public Event BeforeRightClick As ClickEventHandler
'Usage
Dim instance As Bookmark 
Dim handler As ClickEventHandler 

AddHandler instance.BeforeRightClick, handler
public event ClickEventHandler BeforeRightClick
public:
 event ClickEventHandler^ BeforeRightClick {
    void add (ClickEventHandler^ value);
    void remove (ClickEventHandler^ value);
}
JScript does not support events.

Remarks

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

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.

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
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;
}

.NET Framework Security

See Also

Reference

Bookmark Class

Bookmark Members

Microsoft.Office.Tools.Word Namespace