共用方式為


ListObject.BeforeDoubleClick 事件 (2007 系統)

更新: 2008 年 7 月

會在按兩下 ListObject 控制項時發生 (在預設按兩下動作執行之前)。

命名空間:  Microsoft.Office.Tools.Excel
組件:  Microsoft.Office.Tools.Excel.v9.0 (在 Microsoft.Office.Tools.Excel.v9.0.dll 中)

語法

Public Event BeforeDoubleClick As DocEvents_BeforeDoubleClickEventHandler

Dim instance As ListObject
Dim handler As DocEvents_BeforeDoubleClickEventHandler

AddHandler instance.BeforeDoubleClick, handler
public event DocEvents_BeforeDoubleClickEventHandler BeforeDoubleClick

範例

下列程式碼範例會建立 ListObject 和 BeforeDoubleClick 事件處理常式。按兩下 ListObject 時,會顯示訊息,指出 ListObject 是否繫結至資料。

這是示範文件層級自訂的版本。

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);
}

這是示範應用程式層級增益集的版本。

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);
}

使用權限

請參閱

參考

ListObject 類別

ListObject 成員

Microsoft.Office.Tools.Excel 命名空間

變更記錄

日期

記錄

原因

2008 年 7 月

加入應用程式層級增益集的程式碼範例版本。

SP1 功能變更。