共用方式為


XMLNodes.Deselect 事件 (2007 系統)

更新:2007 年 11 月

當游標從 XMLNodes 集合的其中一個節點移出時,便會發生。

命名空間:  Microsoft.Office.Tools.Word
組件:  Microsoft.Office.Tools.Word.v9.0 (在 Microsoft.Office.Tools.Word.v9.0.dll 中)

語法

Public Event Deselect As ContextChangeEventHandler

Dim instance As XMLNodes
Dim handler As ContextChangeEventHandler

AddHandler instance.Deselect, handler
public event ContextChangeEventHandler Deselect

備註

Deselect 事件和 ContextLeave 事件不一樣。如需詳細資訊,請參閱 XMLNodes 控制項

範例

下列程式碼範例會示範 Select、Deselect、ContextEnterContextLeave 事件的事件處理常式。當引發 Select 和 Deselect 事件時,事件處理常式會為選取範圍的邊框加上雙線,或是移除雙線 (視事件而定)。當引發 ContextEnterContextLeave 事件時,事件處理常式會顯示訊息,說明最新選取的節點以及上一個所選節點的名稱。這個範例假設目前文件包含名為 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 命名空間