更新:2007 年 11 月
当光标放置在 XMLNodes 集合的一个节点中时发生此事件。
命名空间: 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 XMLNodes
Dim handler As ContextChangeEventHandler
AddHandler instance.Select, handler
public event ContextChangeEventHandler Select
备注
Select 事件与 ContextEnter 事件不同。有关更多信息,请参见 XMLNodes 控件。
示例
下面的代码示例演示 Select、Deselect、ContextEnter 和 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 + "'.");
}
权限
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。