_XDocumentEventSink2_Event.OnContextChange Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs after the context node changes.
public:
event Microsoft::Office::Interop::InfoPath::SemiTrust::_XDocumentEventSink2_OnContextChangeEventHandler ^ OnContextChange;
event Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnContextChangeEventHandler OnContextChange;
member this.OnContextChange : Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_OnContextChangeEventHandler
Event OnContextChange As _XDocumentEventSink2_OnContextChangeEventHandler
Event Type
Examples
public void OnContextChange(DocContextChangeEvent e)
{
if (e.Type == "ContextNode")
{
IXMLNode expNode=XDocument.DOM.selectSingleNode("//my:field4");
// set field4 with the name of the current context.
expNode.text=e.Context.nodeName;
}
}
public void OnContextChange(DocContextChangeEvent e)
{
if (e.Type == "ContextNode")
{
IXMLNode expNode=XDocument.DOM.selectSingleNode("//my:field4");
// set field4 with the name of the current context.
expNode.text=e.Context.nodeName;
}
}
Remarks
The context node is the XML DOM node mapped to the view that corresponds to the container (or item) with the current XML selection. For example, if the current selection in the view is in a text box, the context node is the node to which the text box is bound. If the current selection is a repeating section, the context node is the node for that item. If two repeating sections are selected, the context node is the ancestor XML DOM for both items mapped to the view.
The OnContextChange event is asynchronous. It does not fire on every change in the context node; instead, it fires after the application has stopped processing other events.
When the document loads, or when a view change occurs, the OnContextChange event will occur after the OnLoadand OnSwitchView events occur.
When the IsUndoRedo property of the DocContextChangeEventObject object is true, the context change was caused by a user's undo or redo operation rather than an explicit user context change. Operations performed within the OnContextChange event that modify the XML DOM should be avoided in response to undo or redo operations, because they may interfere with the user's intention to revert data to a previous state.
For rich text box controls, the OnContextChange event is not raised for context changes within the XHTML content— that is, selection changes to the rich text in the control. The GetContextNodes(Object, Object) method can be used to determine the selection within rich text box controls.