Dela via


ListObject.BeforeDoubleClick Event (2007 System)

Occurs when the ListObject control is double-clicked, before the default double-click action.

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

Syntax

'Declaration
Public Event BeforeDoubleClick As DocEvents_BeforeDoubleClickEventHandler
'Usage
Dim instance As ListObject 
Dim handler As DocEvents_BeforeDoubleClickEventHandler 

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

Examples

The following code example creates a ListObject and a BeforeDoubleClick event handler. When the ListObject is double-clicked, a message is displayed that indicates whether the ListObject is bound to data.

This version is for a document-level customization.

WithEvents List2 As Microsoft.Office.Tools.Excel.ListObject

Private Sub ListObject_BeforeDoubleClick()
    List2 = Me.Controls.AddListObject( _
        Me.Range("A1", "C4"), "List2")
End Sub 


Sub List2_BeforeDoubleClick(ByVal Target As _
    Microsoft.Office.Interop.Excel.Range, ByRef Cancel As Boolean) _
    Handles List2.BeforeDoubleClick
    MessageBox.Show("Data binding is " & List2.IsBinding)

End Sub
Microsoft.Office.Tools.Excel.ListObject list2;
private void ListObject_BeforeDoubleClick()
{
    list2 = this.Controls.AddListObject(
        this.Range["A1", "C4"], "list2");
    list2.BeforeDoubleClick += new 
        Microsoft.Office.Interop.Excel.
        DocEvents_BeforeDoubleClickEventHandler(
        list2_BeforeDoubleClick);
}

void list2_BeforeDoubleClick(Microsoft.Office.Interop.Excel.Range 
    Target, ref bool Cancel)
{
    MessageBox.Show("Data binding is " + list2.IsBinding);
}

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

WithEvents List2 As ListObject

Private Sub ListObject_BeforeDoubleClick()
    Dim vstoWorksheet As Worksheet = CType( _
        Me.Application.ActiveWorkbook.Worksheets(1),  _
        Excel.Worksheet).GetVstoObject()
    List2 = vstoWorksheet.Controls.AddListObject( _
        vstoWorksheet.Range("A1", "C4"), "List2")
End Sub 


Sub List2_BeforeDoubleClick(ByVal Target As  _
    Microsoft.Office.Interop.Excel.Range, ByRef Cancel As Boolean) _
    Handles List2.BeforeDoubleClick
    System.Windows.Forms.MessageBox.Show("Data binding is " & List2.IsBinding)

End Sub
ListObject list2;
private void ListObject_BeforeDoubleClick()
{
    Worksheet vstoWorksheet = ((Excel.Worksheet)
        this.Application.ActiveWorkbook.Worksheets[1]).GetVstoObject();
    list2 = vstoWorksheet.Controls.AddListObject(
        vstoWorksheet.Range["A1", "C4"], "list2");
    list2.BeforeDoubleClick += new
        Excel.DocEvents_BeforeDoubleClickEventHandler(
        list2_BeforeDoubleClick);
}

void list2_BeforeDoubleClick(Microsoft.Office.Interop.Excel.Range
    Target, ref bool Cancel)
{
    System.Windows.Forms.MessageBox.Show("Data binding is " + list2.IsBinding);
}

.NET Framework Security

See Also

Reference

ListObject Class

ListObject Members

Microsoft.Office.Tools.Excel Namespace

Change History

Date

History

Reason

July 2008

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

SP1 feature change.