ContextChangeEventArgs 接口
为 XMLNode 对象的 Select、Deselect、ContextEnter 和 ContextLeave 事件以及 XMLNodes 对象的 ContextEnter、ContextLeave、Select 和 Deselect 事件提供数据。
命名空间: Microsoft.Office.Tools.Word
程序集: Microsoft.Office.Tools.Word(在 Microsoft.Office.Tools.Word.dll 中)
语法
声明
<GuidAttribute("7403c9da-5555-41ed-8288-bf92e780d660")> _
Public Interface ContextChangeEventArgs
[GuidAttribute("7403c9da-5555-41ed-8288-bf92e780d660")]
public interface ContextChangeEventArgs
ContextChangeEventArgs 类型公开以下成员。
属性
名称 | 说明 | |
---|---|---|
NewXMLNode | 获取选择已移动到的 XMLNode 控件。 | |
OldXMLNode | 获取选择已从其移开的 XMLNode 控件。 | |
Reason | 获取选择更改的原因。 | |
Selection | 获取选择的文本,包括 XML 元素。 |
页首
示例
下面的代码示例演示 XMLNode.Select、XMLNode.Deselect、XMLNode.ContextEnter 和 XMLNode.ContextLeave 事件的事件处理程序。引发 XMLNode.Select 和 XMLNode.Deselect 事件时,事件处理程序会根据具体事件为所选内容的边框添加双线或移除双线。引发 XMLNode.ContextEnter 和 XMLNode.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 + "'.");
}