NamedRange.Deselected Event

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Occurs when selection moves from the NamedRange control to an area outside of the NamedRange control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

event DocEvents_SelectionChangeEventHandler Deselected

This event is raised only when the NamedRange control has focus, and then focus is transferred away from the NamedRange control.

The following code example demonstrates a handler for the Deselected event that displays the address of the cell that the selection is transferred to.

This version is for a document-level customization.

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 + ".");
}

This version is for an application-level add-in.

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft