NamedRange.Deselected 事件
当所选内容从 NamedRange 控件移到 NamedRange 控件外部的区域时发生。
命名空间: Microsoft.Office.Tools.Excel
程序集: Microsoft.Office.Tools.Excel(在 Microsoft.Office.Tools.Excel.dll 中)
语法
声明
Event Deselected As DocEvents_SelectionChangeEventHandler
event DocEvents_SelectionChangeEventHandler Deselected
备注
只有当 NamedRange 控件具有焦点,随后又将该焦点从 NamedRange 控件转出时,才引发此事件。
示例
下面的代码示例演示 Deselected 事件的处理程序,该事件显示要将所选内容传输到的单元格的地址。
此版本针对的是文档级自定义项。
Private deselectedRange As Microsoft.Office.Tools.Excel.NamedRange
Private Sub DeselectRange()
deselectedRange = Me.Controls.AddNamedRange( _
Me.Range("B1", "D4"), "deselectedRange")
deselectedRange.Select()
AddHandler Me.deselectedRange.Deselected, _
AddressOf deselectedRange_Deselected
End Sub
Sub deselectedRange_Deselected(ByVal Target As Excel.Range)
Dim targetRange As String = Target.Address(, , _
Excel.XlReferenceStyle.xlA1, , )
MessageBox.Show("The NamedRange control was deselected." & _
" Selection transferred to " & Me.Name & ":" & _
targetRange & ".")
End Sub
Microsoft.Office.Tools.Excel.NamedRange deselectedRange;
private void DeselectRange()
{
deselectedRange = this.Controls.AddNamedRange(
this.Range["B1", "D4"], "deselectedRange");
deselectedRange.Select();
this.deselectedRange.Deselected += new
Microsoft.Office.Interop.Excel.
DocEvents_SelectionChangeEventHandler(
deselectedRange_Deselected);
}
void deselectedRange_Deselected(Excel.Range Target)
{
string targetRange = Target.get_Address(
Excel.XlReferenceStyle.xlA1);
MessageBox.Show("The NamedRange control was deselected." +
" Selection transferred to " + this.Name + ":" +
targetRange + ".");
}
此版本针对的是应用程序级外接程序。
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。