次の方法で共有


XMLNodes.ContextLeave イベント (2007 System)

更新 : 2007 年 11 月

カーソルが XMLNodes コレクションのいずれかのノードまたは子孫のノードから、元のノードのコンテキストの外部にある領域に移動した場合に発生します。

名前空間 :  Microsoft.Office.Tools.Word
アセンブリ :  Microsoft.Office.Tools.Word.v9.0 (Microsoft.Office.Tools.Word.v9.0.dll 内)

構文

'宣言
Public Event ContextLeave As ContextChangeEventHandler
'使用
Dim instance As XMLNodes
Dim handler As ContextChangeEventHandler

AddHandler instance.ContextLeave, handler
public event ContextChangeEventHandler ContextLeave

解説

ContextLeave イベントは Deselect イベントと異なります。ContextLeave イベントはコンテキストが変更されたときにだけ発生します。また、同じ階層レベルでネストされた複数の XMLNodes コントロールに対して発生することがあります。詳細については、「XMLNodes コントロール」を参照してください。

SelectDeselectContextEnter、および ContextLeave イベントのイベント ハンドラを次のコード例に示します。Select イベントと Deselect イベントが発生すると、イベント ハンドラはイベントに応じて選択の境界に二重線を追加するか、または二重線を削除します。ContextEnter イベントと ContextLeave イベントが発生すると、イベント ハンドラは新しく選択されたノードと以前に選択されていたノードの名前を示すメッセージを表示します。この例では、現在の文書に SampleInsertNodes という名前の XMLNodes コレクションが含まれることが前提となっています。

Private Sub SampleInsertNodes_Select(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.Select

    e.Selection.Borders.OutsideLineStyle = _
        Word.WdLineStyle.wdLineStyleDouble
End Sub

Private Sub SampleInsertNodes_Deselect(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.Deselect

    e.Selection.Borders.OutsideLineStyle = _
        Word.WdLineStyle.wdLineStyleNone
End Sub

Private Sub SampleInsertNodes_ContextEnter(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.ContextEnter

    MessageBox.Show("You entered the node '" & _
        e.NewXMLNode.BaseName + "'.")
End Sub

Private Sub SampleInsertNodes_ContextLeave(ByVal sender As Object, _
    ByVal e As Microsoft.Office.Tools.Word.ContextChangeEventArgs) _
    Handles SampleInsertNodes.ContextLeave

    MessageBox.Show("You left the node '" & _
        e.OldXMLNode.BaseName + "'.")
End Sub
private void XMLNodesSelections()
{
    this.SampleInsertNodes.ContextEnter +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_ContextEnter);

    this.SampleInsertNodes.ContextLeave +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_ContextLeave);

    this.SampleInsertNodes.Select +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_Select);

    this.SampleInsertNodes.Deselect +=
        new Microsoft.Office.Tools.Word.ContextChangeEventHandler(
        SampleInsertNodes_Deselect);
}

void SampleInsertNodes_Select(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    e.Selection.Borders.OutsideLineStyle =
        Word.WdLineStyle.wdLineStyleDouble;
}

void SampleInsertNodes_Deselect(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    e.Selection.Borders.OutsideLineStyle =
        Word.WdLineStyle.wdLineStyleNone;
}

void SampleInsertNodes_ContextEnter(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    MessageBox.Show("You entered the node '" +
        e.NewXMLNode.BaseName + "'.");
}

void SampleInsertNodes_ContextLeave(object sender,
    Microsoft.Office.Tools.Word.ContextChangeEventArgs e)
{
    MessageBox.Show("You left the node '" +
        e.OldXMLNode.BaseName + "'.");
}

アクセス許可

  • 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。

参照

参照

XMLNodes クラス

XMLNodes メンバ

Microsoft.Office.Tools.Word 名前空間