ListObject.Deselected 事件
当所选内容从 ListObject 控件移到 ListObject 控件外部时发生。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
Event Deselected As DocEvents_SelectionChangeEventHandler
event DocEvents_SelectionChangeEventHandler Deselected
备注
只有当 ListObject 控件具有焦点,随后又将该焦点从 ListObject 控件移出时,才引发此事件。
示例
下面的代码示例创建一个 ListObject 和一个 Deselected 事件处理程序。在选择 ListObject 以及 ListObject 外部的对象时,将显示一条消息,指出所选内容已发生更改。
此版本针对的是文档级自定义项。
WithEvents DeselectedList As Microsoft.Office.Tools.Excel.ListObject
Private Sub ListObject_Deselected()
DeselectedList = Me.Controls.AddListObject( _
Me.Range("A1", "C4"), "DeselectedList")
End Sub
Sub List1_Deselected(ByVal Target As _
Microsoft.Office.Interop.Excel.Range) Handles DeselectedList.Deselected
MessageBox.Show("The list object is no longer selected.")
End Sub
private void ListObject_Deselected()
{
Microsoft.Office.Tools.Excel.ListObject list1 =
this.Controls.AddListObject(
this.Range["A1", "C4"], "list1");
list1.Deselected += new
Microsoft.Office.Interop.Excel.
DocEvents_SelectionChangeEventHandler(list1_Deselected);
}
void list1_Deselected(Microsoft.Office.Interop.Excel.Range Target)
{
MessageBox.Show("List1 is no longer selected.");
}
此版本针对的是应用程序级外接程序。
WithEvents DeselectedList As ListObject
Private Sub ListObject_Deselected()
Dim NativeWorksheet As Microsoft.Office.Interop.Excel.Worksheet =
Me.Application.Worksheets(1)
Dim vstoWorksheet As Microsoft.Office.Tools.Excel.Worksheet =
Globals.Factory.GetVstoObject(NativeWorksheet)
DeselectedList = vstoWorksheet.Controls.AddListObject( _
vstoWorksheet.Range("A1", "C4"), "DeselectedList")
End Sub
Sub List1_Deselected(ByVal Target As _
Microsoft.Office.Interop.Excel.Range) Handles DeselectedList.Deselected
System.Windows.Forms.MessageBox.Show( _
"The list object is no longer selected.")
End Sub
private void ListObject_Deselected()
{
Worksheet vstoWorksheet =
Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]);
ListObject list1 =
vstoWorksheet.Controls.AddListObject(
vstoWorksheet.Range["A1", "C4"], "list1");
list1.Deselected += new
Excel.DocEvents_SelectionChangeEventHandler(list1_Deselected);
}
void list1_Deselected(Microsoft.Office.Interop.Excel.Range Target)
{
System.Windows.Forms.MessageBox.Show("List1 is no longer selected.");
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。