Evento XMLNodes.AfterInsert (sistema de 2007)

Ocorre quando o usuário adiciona um novo Microsoft.Office.Interop.Word.XMLNode a coleção ou a um de seus descendentes.

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

Sintaxe

Public Event AfterInsert As NodeInsertAndDeleteEventHandler

Dim instance As XMLNodes
Dim handler As NodeInsertAndDeleteEventHandler

AddHandler instance.AfterInsert, handler
public event NodeInsertAndDeleteEventHandler AfterInsert

Exemplos

O exemplo de código a seguir demonstra os manipuladores de eventos para o AfterInsert e BeforeDelete eventos. O código exibe uma caixa de mensagem antes de um Microsoft.Office.Interop.Word.XMLNode é excluído do documento e após um Microsoft.Office.Interop.Word.XMLNode é adicionado ao documento. O exemplo também usa o Add Para adicionar um novo elemento a um XMLNodes coleção em um intervalo especificado e programaticamente elevar a AfterInsert evento. Este exemplo assume que o documento corrente contém uma XMLNodes coleção denominada SampleInsertNodes, que tem um pai XMLNode chamada SampleNode.

PrivateSub XMLNodeAddAndDelete()
    Dim range1 AsObject = Me.SampleInsertNodes(1).Range

    ' This will raise the AfterInsert event.Dim node1 As Word.XMLNode = _
        Me.SampleInsertNodes.Add("MemoFrom", _
        Me.SampleNode.NamespaceURI, range1)
EndSubPrivateSub SampleInsertNodes_AfterInsert(ByVal sender AsObject, _
    ByVal e As Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs) _
    Handles SampleInsertNodes.AfterInsert

    If e.InUndoRedo Then
        MessageBox.Show("A child element of SampleInsertNodes was " & _
            "inserted as a result of an undo or redo operation.")
    Else
        MessageBox.Show("A child element of SampleInsertNodes " & _
            "was inserted.")
    EndIfEndSubPrivateSub SampleInsertNodes_BeforeDelete(ByVal sender AsObject, _
    ByVal e As Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs) _
    Handles SampleInsertNodes.BeforeDelete

    If e.InUndoRedo Then
        MessageBox.Show("A child element of SampleInsertNodes " & _
            "is about to be deleted as a result of an undo or " & _
            "redo operation.")
    Else
        MessageBox.Show("A child element of SampleInsertNodes " & _
        "is about to be deleted.")
    EndIfEndSub
privatevoid XMLNodeAddAndDelete()
{
    object range1 = this.SampleInsertNodes[1].Range;

    this.SampleInsertNodes.AfterInsert +=
        new Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventHandler(
        SampleInsertNodes_AfterInsert);

    this.SampleInsertNodes.BeforeDelete +=
        new Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventHandler(
        SampleInsertNodes_BeforeDelete);

    // This will raise the AfterInsert event.
    Word.XMLNode node1 = this.SampleInsertNodes.Add("MemoFrom",
        this.SampleNode.NamespaceURI, ref range1);
}

void SampleInsertNodes_AfterInsert(object sender,
    Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs e)
{
    if (e.InUndoRedo)
    {
        MessageBox.Show("A child element of SampleInsertNodes was " +
            "inserted as a result of an undo or redo operation.");
    }
    else
    {
        MessageBox.Show("A child element of SampleInsertNodes " +
            "was inserted.");
    }
}

void SampleInsertNodes_BeforeDelete(object sender,
    Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs e)
{
    if (e.InUndoRedo)
    {
        MessageBox.Show("A child element of SampleInsertNodes " +
            "is about to be deleted as a result of an undo or " +
            "redo operation.");
    }
    else
    {
        MessageBox.Show("A child element of SampleInsertNodes " +
            "is about to be deleted.");
    }
}

Permissões

Consulte também

Referência

XMLNodes Classe

Membros XMLNodes

Namespace Microsoft.Office.Tools.Word