ListObject.BeforeRightClick 事件
当在默认的右击操作之前右击 ListObject 控件时发生。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
Event BeforeRightClick As DocEvents_BeforeRightClickEventHandler
event DocEvents_BeforeRightClickEventHandler BeforeRightClick
示例
下面的代码示例创建一个 ListObject 和一个 BeforeRightClick 事件处理程序。在右击列表对象时,会显示一条消息,指示列表对象是否绑定到数据。
此版本针对的是文档级自定义项。
WithEvents List3 As Microsoft.Office.Tools.Excel.ListObject
Private Sub ListObject_BeforeRightClick()
List3 = Me.Controls.AddListObject( _
Me.Range("A1", "C4"), "List3")
End Sub
Sub List3_BeforeRightClick(ByVal Target As _
Microsoft.Office.Interop.Excel.Range, _
ByRef Cancel As Boolean) Handles List3.BeforeRightClick
MessageBox.Show("Data binding is " & List3.IsBinding)
Cancel = True
End Sub
Microsoft.Office.Tools.Excel.ListObject list3;
private void ListObject_BeforeRightClick()
{
list3 = this.Controls.AddListObject(
this.Range["A1", "C4"], "list3");
list3.BeforeRightClick += new
Microsoft.Office.Interop.Excel.
DocEvents_BeforeRightClickEventHandler(
list3_BeforeRightClick);
}
void list3_BeforeRightClick(Microsoft.Office.Interop.Excel.Range
Target, ref bool Cancel)
{
MessageBox.Show("Data binding is " + list3.IsBinding);
Cancel = true;
}
此版本针对的是应用程序级外接程序。
WithEvents List3 As ListObject
Private Sub ListObject_BeforeRightClick()
Dim NativeWorksheet As Microsoft.Office.Interop.Excel.Worksheet =
Me.Application.Worksheets(1)
Dim vstoWorksheet As Microsoft.Office.Tools.Excel.Worksheet =
Globals.Factory.GetVstoObject(NativeWorksheet)
List3 = vstoWorksheet.Controls.AddListObject( _
vstoWorksheet.Range("A1", "C4"), "List3")
End Sub
Sub List3_BeforeRightClick(ByVal Target As _
Microsoft.Office.Interop.Excel.Range, _
ByRef Cancel As Boolean) Handles List3.BeforeRightClick
System.Windows.Forms.MessageBox.Show("Data binding is " & List3.IsBinding)
Cancel = True
End Sub
ListObject list3;
private void ListObject_BeforeRightClick()
{
Worksheet vstoWorksheet =
Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]);
list3 = vstoWorksheet.Controls.AddListObject(
vstoWorksheet.Range["A1", "C4"], "list3");
list3.BeforeRightClick += new
Excel.DocEvents_BeforeRightClickEventHandler(
list3_BeforeRightClick);
}
void list3_BeforeRightClick(Microsoft.Office.Interop.Excel.Range
Target, ref bool Cancel)
{
System.Windows.Forms.MessageBox.Show("Data binding is " + list3.IsBinding);
Cancel = true;
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。