XMLNode.Deselect 事件
當游標移出 XMLNode 控制項時便會發生。
命名空間: Microsoft.Office.Tools.Word
組件: Microsoft.Office.Tools.Word (在 Microsoft.Office.Tools.Word.dll 中)
語法
'宣告
Event Deselect As ContextChangeEventHandler
event ContextChangeEventHandler Deselect
備註
Deselect 事件和 ContextLeave 事件不一樣。如需詳細資訊,請參閱XMLNode 控制項。
範例
下列程式碼範例會示範 Select、Deselect、ContextEnter 和 ContextLeave 事件的事件處理常式。當引發 Select 和 Deselect 事件時,事件處理常式會為選取範圍的邊框加上雙線,或是移除雙線 (視事件而定)。當引發 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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。