Partilhar via


Evento XMLNode.AfterInsert (sistema de 2007)

Ocorre quando o usuário adiciona um novo XMLNode controle ao documento.

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 XMLNode
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 XMLNode é excluído do documento e após um XMLNode é adicionado ao documento. O exemplo também usa o RemoveChild método para excluir um nó e aumentar programaticamente a BeforeDelete evento. Este exemplo assume que o documento corrente contém uma XMLNode chamada CustomerNode que contém um nó filho chamado CustomerDateNode.

PrivateSub XMLNodeInsertAndDelete()
    Me.CustomerNode.RemoveChild(Me.CustomerDateNode.InnerObject)
EndSubPrivateSub XMLNode_BeforeDelete(ByVal sender AsObject, _
    ByVal e As Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs) _
    Handles CustomerDateNode.BeforeDelete

    Dim tempNode As Microsoft.Office.Tools.Word.XMLNode = _
        CType(sender, Microsoft.Office.Tools.Word.XMLNode)
    If e.InUndoRedo Then
        MsgBox(tempNode.BaseName & " element is about to be " & _
            "deleted as a result of an undo or redo operation.")
    Else
        MsgBox(tempNode.BaseName & " element is about to be " & _
            "deleted.")
    EndIfEndSubPrivateSub XMLNode_AfterInsert(ByVal sender AsObject, _
    ByVal e As Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs) _
    Handles CustomerDateNode.AfterInsert

    Dim tempNode As Microsoft.Office.Tools.Word.XMLNode = _
        CType(sender, Microsoft.Office.Tools.Word.XMLNode)

    If e.InUndoRedo Then
        MsgBox(tempNode.BaseName & " element was " & _
            "inserted as a result of an undo or redo operation.")
    Else
        MsgBox(tempNode.BaseName & " element was inserted.")
    EndIfEndSub
privatevoid XMLNodeInsertAndDelete()
{
    this.CustomerDateNode.AfterInsert +=
        new Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventHandler(
        XMLNode_AfterInsert);

    this.CustomerDateNode.BeforeDelete +=
        new Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventHandler(
        XMLNode_BeforeDelete);

    this.CustomerNode.RemoveChild(this.CustomerDateNode.InnerObject);
}

void XMLNode_BeforeDelete(object sender, 
    Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs e)
{
    Microsoft.Office.Tools.Word.XMLNode tempNode =
        (Microsoft.Office.Tools.Word.XMLNode)sender;

    if (e.InUndoRedo)
    {
        MessageBox.Show(tempNode.BaseName + " element is about to be " +
            "deleted as a result of an undo or redo operation.");
    }
    else
    {
        MessageBox.Show(tempNode.BaseName + " element is about to be " +
            "deleted.");
    }
}


void XMLNode_AfterInsert(object sender,
    Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs e)
{
    Microsoft.Office.Tools.Word.XMLNode tempNode =
        (Microsoft.Office.Tools.Word.XMLNode)sender;

    if (e.InUndoRedo)
    {
        MessageBox.Show(tempNode.BaseName + " element was " +
            "inserted as a result of an undo or redo operation.");
    }
    else
    {
        MessageBox.Show(tempNode.BaseName + " element was inserted.");
    }
}

Permissões

Consulte também

Referência

XMLNode Classe

Membros XMLNode

Namespace Microsoft.Office.Tools.Word