共用方式為


Document.BeforeRightClick 事件

在文件視窗的編輯區域上按一下滑鼠右鍵時,於預設的按一下滑鼠右鍵動作之前發生。

命名空間:  Microsoft.Office.Tools.Word
組件:   Microsoft.Office.Tools.Word.v4.0.Utilities (在 Microsoft.Office.Tools.Word.v4.0.Utilities.dll 中)
  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 命名空間