Share via


XMLNodes.Deselect Event (2007 System)

Occurs when the cursor is moved out of one of the nodes of the XMLNodes collection.

Namespace:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word.v9.0 (in Microsoft.Office.Tools.Word.v9.0.dll)

Syntax

'Declaration
Public Event Deselect As ContextChangeEventHandler
'Usage
Dim instance As XMLNodes 
Dim handler As ContextChangeEventHandler 

AddHandler instance.Deselect, handler
public event ContextChangeEventHandler Deselect
public:
 event ContextChangeEventHandler^ Deselect {
    void add (ContextChangeEventHandler^ value);
    void remove (ContextChangeEventHandler^ value);
}
JScript does not support events.

Remarks

The Deselect event differs from the ContextLeave event. For more information, see XMLNodes Control.

Examples

The following code example demonstrates event handlers for the Select, Deselect, ContextEnter, and ContextLeave events. When the Select and Deselect events are raised, the event handlers add double lines to the borders of the selection or remove the double lines, depending on the event. When the ContextEnter and ContextLeave events are raised, the event handlers display messages that state the names of the newly selected node and the previously selected node. This example assumes that the current document contains an XMLNodes collection named SampleInsertNodes.

Private Sub SampleInsertNodes_Select(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.Select

    e.Selection.Borders.OutsideLineStyle = _
        Word.WdLineStyle.wdLineStyleDouble
End Sub 

Private Sub SampleInsertNodes_Deselect(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.Deselect

    e.Selection.Borders.OutsideLineStyle = _
        Word.WdLineStyle.wdLineStyleNone
End Sub 

Private Sub SampleInsertNodes_ContextEnter(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.ContextEnter

    MessageBox.Show("You entered the node '" & _
        e.NewXMLNode.BaseName + "'.")
End Sub 

Private Sub SampleInsertNodes_ContextLeave(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.ContextLeave

    MessageBox.Show("You left the node '" & _
        e.OldXMLNode.BaseName + "'.")
End Sub
private void XMLNodesSelections()
{
    this.SampleInsertNodes.ContextEnter +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_ContextEnter);

    this.SampleInsertNodes.ContextLeave +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_ContextLeave);

    this.SampleInsertNodes.Select +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_Select);

    this.SampleInsertNodes.Deselect +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_Deselect);
}

void SampleInsertNodes_Select(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    e.Selection.Borders.OutsideLineStyle =
        Word.WdLineStyle.wdLineStyleDouble;
}

void SampleInsertNodes_Deselect(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    e.Selection.Borders.OutsideLineStyle =
        Word.WdLineStyle.wdLineStyleNone;
}

void SampleInsertNodes_ContextEnter(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    MessageBox.Show("You entered the node '" +
        e.NewXMLNode.BaseName + "'.");
}

void SampleInsertNodes_ContextLeave(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    MessageBox.Show("You left the node '" +
        e.OldXMLNode.BaseName + "'.");
}

.NET Framework Security

See Also

Reference

XMLNodes Class

XMLNodes Members

Microsoft.Office.Tools.Word Namespace