NodeInsertAndDeleteEventArgs Classe (sistema de 2007)

Fornece dados para o AfterInsert e BeforeDelete eventos de um XMLNode controle e para o AfterInsert e BeforeDelete eventos de um XMLNodes controle.

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

Sintaxe

<PermissionSetAttribute(SecurityAction.Demand, Name := "FullTrust")> _
Public NotInheritable Class NodeInsertAndDeleteEventArgs _
    Inherits EventArgs

Dim instance As NodeInsertAndDeleteEventArgs
[PermissionSetAttribute(SecurityAction.Demand, Name = "FullTrust")]
public sealed class NodeInsertAndDeleteEventArgs : EventArgs

Exemplos

O exemplo de código a seguir demonstra os manipuladores de eventos para o AfterInsert e BeforeDelete eventos. Esses manipuladores de eventos exibir 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.");
    }
}

Hierarquia de herança

System.Object
  System.EventArgs
    Microsoft.Office.Tools.Word.NodeInsertAndDeleteEventArgs

Acesso thread-safe

Quaisquer membros static (Shared no Visual Basic) públicos deste tipo são thread-safe. Não há garantia de que qualquer membro de instância seja thread-safe.

Consulte também

Referência

Membros NodeInsertAndDeleteEventArgs

Namespace Microsoft.Office.Tools.Word