Aracılığıyla paylaş


ContextChangeEventHandler Temsilci

İşler yöntemini gösteren Select, Deselect, ContextEnter ve ContextLeave olayların bir XMLNode nesne ve ContextEnter, ContextLeave, Select, ve Deselect olayların bir XMLNodes nesne.

Ad alanı:  Microsoft.Office.Tools.Word
Derleme:  Microsoft.Office.Tools.Word (Microsoft.Office.Tools.Word.dll içinde)

Sözdizimi

'Bildirim
Public Delegate Sub ContextChangeEventHandler ( _
    sender As Object, _
    e As ContextChangeEventArgs _
)
public delegate void ContextChangeEventHandler(
    Object sender,
    ContextChangeEventArgs e
)

Parametreler

Açıklamalar

Oluşturduğunuzda, bir ContextChangeEventHandler temsilci, sizi kişisel olarak tanımlamak yöntemi, ele olay. Olay, olay işleyicisi ile ilişkilendirmek için olaya temsilcinin oluşumu ekleyin. Her temsilci kaldırana kadar olay gerçekleştiğinde olay işleyicisi çağrılır. Temsilciler hakkında daha fazla bilgi için bkz: Events and Delegates.

Örnekler

Aşağıdaki kod örneği için olay işleyicilerini gösterir XMLNode.Select, XMLNode.Deselect, XMLNode.ContextEnter, ve XMLNode.ContextLeave olayları. Zaman XMLNode.Select ve XMLNode.Deselect olayları harekete geçirilen, olay işleyicilerini seçim kenarlıklarını çift çizgi ekleyip bağlı çift çizgiolay. Zaman XMLNode.ContextEnter ve XMLNode.ContextLeave olayları harekete geçirilen, olay işleyicilerini görüntü adlarını yeni seçilen düğüm ve durum iletileriönceden seçilen düğümü. Bu örnek, geçerli belge içerdiğini varsayar bir XMLNode adlı 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 + "'.");
}

Ayrıca bkz.

Başvuru

Microsoft.Office.Tools.Word Ad Alanı