XMLNode.Select 事件 (2007 system)
更新:2007 年 11 月
当光标置于 XMLNode 控件内时发生。
命名空间: Microsoft.Office.Tools.Word
程序集: Microsoft.Office.Tools.Word.v9.0(在 Microsoft.Office.Tools.Word.v9.0.dll 中)
语法
声明
Public Event Select As ContextChangeEventHandler
用法
Dim instance As XMLNode
Dim handler As ContextChangeEventHandler
AddHandler instance.Select, handler
public event ContextChangeEventHandler Select
备注
Select 事件与 ContextEnter 事件不同。有关更多信息,请参见 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 + "'.");
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。