XMLNodes.Select 事件
当光标放置在 XMLNodes 集合的一个节点中时发生此事件。
命名空间: Microsoft.Office.Tools.Word
程序集: Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)
语法
声明
Event Select As ContextChangeEventHandler
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)
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)
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)
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)
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 + "'.");
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关更多信息,请参见通过部分受信任的代码使用库。