Zdarzenie XMLNodes.ContextLeave

Występuje, gdy kursor zostanie przeniesiony z jednego z węzłów lub węzły podrzędne z XMLNodes kolekcji, aby obszar poza kontekstem oryginalnego węzła.

Przestrzeń nazw:  Microsoft.Office.Tools.Word
Zestaw:  Microsoft.Office.Tools.Word (w Microsoft.Office.Tools.Word.dll)

Składnia

'Deklaracja
Event ContextLeave As ContextChangeEventHandler
event ContextChangeEventHandler ContextLeave

Uwagi

ContextLeave Zdarzenia różni się od Deselect zdarzenia.ContextLeave Zdarzenie jest wywoływane tylko wtedy, gdy zmienia kontekst i może zostać podniesiony do wielu XMLNodes formanty zagnieżdżone na tym samym poziomie hierarchii.Aby uzyskać więcej informacji, zobacz Formant XMLNodes.

Przykłady

Poniższy przykład kodu demonstruje obsługi zdarzeń Select, Deselect, ContextEnter, i ContextLeave zdarzenia.Gdy Select i Deselect zdarzenia są wywoływane, obsługi zdarzeń dodać podwójne linie obramowania zaznaczenia lub usunąć podwójne linie, w zależności od zdarzenia.Gdy ContextEnter i ContextLeave zdarzenia są wywoływane, obsługi zdarzeń wyświetlania komunikatów, które podane nazwy nowo wybrany węzeł i wcześniej zaznaczonego węzła.W tym przykładzie założono, że bieżący dokument zawiera XMLNodes kolekcji o nazwie SampleInsertNodes.

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


    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)


    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)


    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)


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

Zabezpieczenia programu .NET Framework

Zobacz też

Informacje

XMLNodes Interfejs

Przestrzeń nazw Microsoft.Office.Tools.Word