Document.BeforeDoubleClick Event (2007 System)

Occurs when the editing area of the document window is double-clicked, before the default double-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 BeforeDoubleClick As ClickEventHandler
'Usage
Dim instance As Document 
Dim handler As ClickEventHandler 

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

Remarks

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

Examples

The following code example displays a message when you double-click the document.

This version is for a document-level customization.

Private Sub DocumentBeforeDoubleClick()
    AddHandler Me.BeforeDoubleClick, AddressOf ThisDocument_BeforeDoubleClick
End Sub 

Private Sub ThisDocument_BeforeDoubleClick(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.ClickEventArgs)
    MessageBox.Show(Me.Name & " was double-clicked.")
End Sub
private void DocumentBeforeDoubleClick()
{
    this.BeforeDoubleClick += new Microsoft.Office.Tools.Word.ClickEventHandler(ThisDocument_BeforeDoubleClick);
}

void ThisDocument_BeforeDoubleClick(object sender, Microsoft.Office.Tools.Word.ClickEventArgs e)
{
    MessageBox.Show(this.Name + " was double-clicked.");
}

This version is for an application-level add-in.

Private Sub DocumentBeforeDoubleClick()
    Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
    AddHandler vstoDoc.BeforeDoubleClick, AddressOf ThisDocument_BeforeDoubleClick
End Sub 

Private Sub ThisDocument_BeforeDoubleClick(ByVal sender As Object, ByVal e As Microsoft.Office.Tools.Word.ClickEventArgs)
    Dim vstoDoc As Document = Me.Application.ActiveDocument.GetVstoObject()
    System.Windows.Forms.MessageBox.Show(vstoDoc.Name & " was double-clicked.")
End Sub
private void DocumentBeforeDoubleClick()
{
    Document vstoDoc = this.Application.ActiveDocument.GetVstoObject();
    vstoDoc.BeforeDoubleClick += new Microsoft.Office.Tools.Word.ClickEventHandler(ThisDocument_BeforeDoubleClick);            
}

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

.NET Framework Security

See Also

Reference

Document Class

Document Members

Microsoft.Office.Tools.Word Namespace

Change History

Date

History

Reason

July 2008

Added a version of the code example for an application-level add-in.

SP1 feature change.