Share via


ListObject.BeforeDoubleClick Event

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

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

Syntax

'Declaration
Event BeforeDoubleClick As DocEvents_BeforeDoubleClickEventHandler
event DocEvents_BeforeDoubleClickEventHandler BeforeDoubleClick

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 NativeWorksheet As Microsoft.Office.Interop.Excel.Worksheet =
        Me.Application.Worksheets(1)
    Dim vstoWorksheet As Microsoft.Office.Tools.Excel.Worksheet =
            Globals.Factory.GetVstoObject(NativeWorksheet)
    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 = 
        Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]);
    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 Interface

Microsoft.Office.Tools.Excel Namespace