Document.BeforeRightClick 事件

在默认的右击操作执行之前,在文档窗口的编辑区域被右击时发生。

命名空间:  Microsoft.Office.Tools.Word
程序集:  Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)

语法

声明
Event BeforeRightClick As ClickEventHandler
event ClickEventHandler BeforeRightClick

备注

若要防止发生默认的右击操作,请将所提供的 CancelEventArgs 对象的 Cancel 参数设置为 true。

示例

下面的代码示例在您右击文档时显示一条消息。 此示例针对的是应用程序级外接程序。

Private Sub DocumentBeforeRightClick()
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    AddHandler vstoDoc.BeforeRightClick, AddressOf ThisDocument_BeforeRightClick
End Sub

Private Sub ThisDocument_BeforeRightClick(ByVal sender As Object, ByVal e _
    As Microsoft.Office.Tools.Word.ClickEventArgs)
    Dim vstoDoc As Document = Globals.Factory.GetVstoObject(Me.Application.ActiveDocument)
    System.Windows.Forms.MessageBox.Show(vstoDoc.Name & " was right-clicked.")
    e.Cancel = True
End Sub
private void DocumentBeforeRightClick()
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    vstoDoc.BeforeRightClick += new Microsoft.Office.Tools.Word.ClickEventHandler(ThisDocument_BeforeRightClick);
}

void ThisDocument_BeforeRightClick(object sender, Microsoft.Office.Tools.Word.ClickEventArgs e)
{
    Document vstoDoc = Globals.Factory.GetVstoObject(this.Application.ActiveDocument);
    System.Windows.Forms.MessageBox.Show(vstoDoc.Name + " was right-clicked.");
    e.Cancel = true;
}

.NET Framework 安全性

请参见

参考

Document 接口

Microsoft.Office.Tools.Word 命名空间