![]() If you want to bind a content control to a single element in a custom XML part, you do not have to use an XML schema. ![]() This enables you to access the contents of the XML file at run time. This step embeds the XML file as a resource in the assembly when you build the project. In the Properties window, select the Build Action property, and then change the value to Embedded Resource. In Solution Explorer, choose the employees.xml file. Replace the contents of the employees.xml file with the following text. ![]() The employees.xml file opens in the Code Editor. Name the file employees.xml, and then choose the Add button. On the Project menu, choose Add New Item. To make the data available at run time, embed the XML file as a resource in the customization assembly. In this walkthrough, you create an XML file that contains the employee data, marked by elements that you will bind to the content controls in the document. Typically, you will obtain XML data to store in a custom XML part from an external source, such as a file or a database. The next step is to attach the data that you want to display to the document in an XML file. If you run the project now, you can type text in the first row and select a date in the second row. That is the entire user interface for this project. In the Controls group, choose the Drop-Down List button to add a DropDownListContentControl to the last cell. In the second column of the table, choose the third row (next to Title). In the Controls group, choose the Date Picker button to add a DatePickerContentControl to the second cell. In the second column of the table, choose the second row (next to Hire Date). In the Controls group, choose the Text button to add a PlainTextContentControl to the first cell. For more information, see How to: Show the developer tab on the ribbon. If the Developer tab is not visible, you must first show it. In the second column of the table, choose the first row (next to Employee Name). Type text in the first column so that it resembles the following column: In the Tables group, choose Table, and insert a table with 2 columns and 3 rows. In the Word document that is hosted in the Visual Studio designer, on the Ribbon, choose the Insert tab. Visual Studio opens the new Word document in the designer and adds the EmployeeControls project to Solution Explorer.Ĭreate a table that contains three different types of content controls where the user can view or edit information about an employee. For more information, see How to: Create Office projects in Visual Studio. To create a new Word document projectĬreate a Word document project with the name EmployeeControls. ![]() For more information, see Configure a computer to develop Office solutions.Ĭreate a Word document that you will use in the walkthrough. You need the following components to complete this walkthrough:Īn edition of Visual Studio that includes the Microsoft Office developer tools. For more information, see Personalize the IDE. The Visual Studio edition that you have and the settings that you use determine these elements. Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. This walkthrough illustrates the following tasks:Īdding content controls to the Word document in a document-level project at design time.Ĭreating an XML data file and an XML schema that defines the elements to bind to the content controls.Īttaching the XML schema to the document at design time.Īdding the contents of the XML file to a custom XML part in the document at run time.īinding the content controls to elements in the custom XML part.īinding a DropDownListContentControl to a set of values that are defined in the XML schema. Any changes that you make to the text in the content controls are saved in the custom XML part. When you open the document, the content controls display the values of the XML elements. The example document in this walkthrough displays employee information that is stored in a custom XML part. You can control the display of this data by binding content controls to elements in a custom XML part. Word enables you to store XML data, named custom XML parts, in a document. For more information, see Features available by Office application and project type. This walkthrough demonstrates how to bind content controls in a document-level customization for Word to XML data that is stored in the document.Īpplies to: The information in this topic applies to document-level projects for Word. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |