Condividi tramite


Interfaccia ContextChangeEventArgs

fornisce i dati per Select, Deselect, ContextEnter e ContextLeave eventi di un oggetto XMLNode oggetto e ContextEnter, ContextLeave, Selecte Deselect eventi di un oggetto XMLNodes oggetto.

Spazio dei nomi:  Microsoft.Office.Tools.Word
Assembly:  Microsoft.Office.Tools.Word (in Microsoft.Office.Tools.Word.dll)

Sintassi

'Dichiarazione
<GuidAttribute("7403c9da-5555-41ed-8288-bf92e780d660")> _
Public Interface ContextChangeEventArgs
[GuidAttribute("7403c9da-5555-41ed-8288-bf92e780d660")]
public interface ContextChangeEventArgs

Il tipo ContextChangeEventArgs espone i seguenti membri.

Proprietà

  Nome Descrizione
Proprietà pubblica NewXMLNode ottiene XMLNode verificare che la selezione è stata spostata.
Proprietà pubblica OldXMLNode ottiene XMLNode verificare che la selezione è stata spostata.
Proprietà pubblica Reason Ottiene la ragione per cui la selezione è stata modificata.
Proprietà pubblica Selection Ottiene il testo selezionato, inclusi gli elementi XML.

In alto

Esempi

Nell'esempio di codice seguente vengono illustrati i gestori eventi per XMLNode.Select, XMLNode.Deselect, XMLNode.ContextEntere XMLNode.ContextLeave eventi. quando XMLNode.Select e XMLNode.Deselect gli eventi vengono generati, i gestori eventi aggiunti raddoppiano le linee ai bordi della selezione o rimuovono raddoppiano le righe, come l'evento. quando XMLNode.ContextEnter e XMLNode.ContextLeave gli eventi vengono generati, consente di visualizzare i messaggi dei gestori eventi che indicano i nomi del nodo appena selezionato e il nodo selezionato in precedenza. In questo esempio si presuppone che il documento contenga corrente XMLNode denominato CustomerNode.

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

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

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

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

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

    MsgBox("You entered the node '" & e.NewXMLNode.BaseName & "'.")
End Sub

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

    MsgBox("You left the node '" & e.OldXMLNode.BaseName & "'.")
End Sub
private void XMLNodeSelections()
{
    this.CustomerNode.ContextEnter +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        CustomerNode_ContextEnter);

    this.CustomerNode.ContextLeave +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        CustomerNode_ContextLeave);

    this.CustomerNode.Select += 
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        CustomerNode_Select); 

    this.CustomerNode.Deselect +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        CustomerNode_Deselect);
}

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

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

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

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

Vedere anche

Riferimenti

Spazio dei nomi Microsoft.Office.Tools.Word