Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Word Solutions
Word Host Controls
 XMLNode Control

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0)
XMLNode Control

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Word 2007

  • Word 2003

For more information, see Features Available by Application and Project Type.

The XMLNode control is a mapped XML node object that exposes events and can be bound to data. The XMLNode control is created only when a non-repeating schema element is mapped onto a Microsoft Office Word document. After Visual Studio Tools for Office creates the XML node, you can program against it directly without having to traverse the Word object model.

The XMLNode control can be deleted only by removing the element mapping in Word.

An XMLNode control supports simple data binding. The XML node should be bound to a data source by using the DataBindings property. If the data in the bound dataset is updated, the XMLNode control reflects the changes.

Formatting that can be applied to a Microsoft.Office.Interop.Word..::.XMLNode object can be applied to a Microsoft.Office.Tools.Word..::.XMLNode control. This includes fonts, underline styles, and character styles.

You can capture an event when the user moves his or her cursor inside the context of a particular XMLNode control. For example, you might have an XMLNode control named Customer that has a child XMLNode control named Company, and Company has two child XMLNode controls named CompanyName and CompanyRegion as follows:

<Customer>
    <Company>
        <CompanyName>
        <CompanyRegion>

If you want to show a control on the actions pane whenever the cursor is moved into the Company node, it should not matter whether the cursor is placed in CompanyName or CompanyRegion because they are both within the context of Company. In this case, you can write your code in the ContextEnter event of Company.

In most cases, when the cursor enters an XMLNode control, both the Select and ContextEnter events are raised. The following table shows the differences between these events.

Select Event

ContextEnter Event

Occurs when the cursor is placed inside an XMLNode.

Occurs when the cursor is placed inside an XMLNode or one of its descendent nodes, from an area outside of the context of the node. In other words, it is raised only when the context changes.

For example, when you move the cursor from outside of Customer into CompanyName, the ContextEnter event for Customer, Company, and CompanyName is raised. If you then move the cursor from CompanyName to CompanyRegion, only the ContextEnter event for CompanyRegion is raised because you are still within the context of both Company and Customer.

The same differences exist between the ContextLeave event and Deselect event.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker