Share via


XMLNode.ContextLeave 이벤트

커서가 XMLNode 컨트롤 또는 해당 하위 노드 중 하나에서 원래 노드의 컨텍스트 외부 영역으로 이동하면 발생합니다.

네임스페이스:  Microsoft.Office.Tools.Word
어셈블리:  Microsoft.Office.Tools.Word(Microsoft.Office.Tools.Word.dll)

구문

‘선언
Event ContextLeave As ContextChangeEventHandler
event ContextChangeEventHandler ContextLeave

설명

ContextLeave 이벤트는 Deselect 이벤트와 다릅니다. ContextLeave 이벤트는 컨텍스트가 변경되는 경우에만 발생합니다. 자세한 내용은 XMLNode 컨트롤을 참조하십시오.

예제

다음 코드 예제에서는 Select, Deselect, ContextEnter 및 ContextLeave 이벤트의 이벤트 처리기를 보여 줍니다. SelectDeselect 이벤트가 발생하면 이벤트 처리기가 이벤트에 따라 선택 영역의 테두리에서 이중선을 추가하거나 제거합니다. ContextEnter 및 ContextLeave 이벤트가 발생하면 이벤트 처리기가 새로 선택된 노드와 이전에 선택된 노드의 이름을 나타내는 메시지를 표시합니다. 이 예제에서는 현재 문서에 CustomerNode라는 XMLNode가 포함되어 있다고 가정합니다.

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 + "'.");
}

.NET Framework 보안

  • 직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분 신뢰 코드에서 라이브러리 사용을 참조하십시오.

참고 항목

참조

XMLNode 인터페이스

Microsoft.Office.Tools.Word 네임스페이스