Compartir a través de


DocumentBase.BeforeRightClick Event

Definition

Occurs when the editing area of the document window is right-clicked, before the default right-click action.

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

Event Type

Examples

The following code example displays a message when you right-click the document. To use this example, run it from the ThisDocument class in a document-level project.

private void DocumentBeforeRightClick()
{
    this.BeforeRightClick += new Microsoft.Office.Tools.Word.ClickEventHandler(ThisDocument_BeforeRightClick);
}

void ThisDocument_BeforeRightClick(object sender, Microsoft.Office.Tools.Word.ClickEventArgs e)
{
    MessageBox.Show(this.Name + " was right-clicked.");
    e.Cancel = true;
}
Private Sub DocumentBeforeRightClick()
    AddHandler Me.BeforeRightClick, AddressOf ThisDocument_BeforeRightClick
End Sub

Private Sub ThisDocument_BeforeRightClick(ByVal sender As Object, ByVal e _
    As Microsoft.Office.Tools.Word.ClickEventArgs)
    MessageBox.Show(Me.Name & " was right-clicked.")
    e.Cancel = True
End Sub

Remarks

To prevent the default right-click action from occurring, set the Cancel argument of the provided CancelEventArgs object to true.

Applies to