ListObject.BeforeDoubleClick 事件
当在默认的双击操作之前双击 ListObject 控件时发生。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
Event BeforeDoubleClick As DocEvents_BeforeDoubleClickEventHandler
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 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 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。