Content Controls Sample
[このトピックはプレリリース版のため将来変更される可能性があります。また、プレースホルダとしてブランクのトピックが含まれています。]
This sample demonstrates how to use content controls on a Microsoft Office Word 2007 document. The document includes a table that contains content controls in the second column, and brief descriptions for each content control in the first column. The sample also demonstrates how content controls can span page breaks.
Security Note |
---|
This sample code is provided to illustrate a concept and should not be used in applications, because it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended. |
For information about how to install the sample project on your computer, see How to: Download Sample Files in Help Topics.
To run this sample
Press F5.
In the first row of the table, verify that you cannot edit or delete the rich text control.
In the second row of the table, type a number in the plain text control.
Verify that the control accepts only numbers from 1 through 100.
In the third row of the table, click the icon in the picture control and browse to an image to display it.
In the fourth row of the table, select one of the job titles or type your own job title in the combo box control.
Verify that a warning appears if you click outside the combo box control without selecting or typing a title.
In the fifth row of the table, select one of the levels in the list.
Verify that the control does not accept values greater than 7 if the title Sales Representative is selected in the combo box control in the fourth row.
In the sixth row of the table, select a date in the date picker control.
In the last row of the table, type a street address, city, state, and zip code.
Verify that you cannot delete any of the controls that are nested in the group control.
In the rich text control after the table, insert a page break. Verify that the rich text control spans the page break.
Requirements
This sample requires the following applications:
Visual Studio Tools for Office.
Microsoft Office Word 2007.
Demonstrates
This sample demonstrates the following concepts:
Using the following content controls in a table on a Word document:
Validating text entered in a content control by an end user (for example, verifying that an entered number is between 0 and 101). The sample does this by handling the Validating event.
Performing an action after the user clicks outside a content control. The sample does this by handling the ContentControlOnExit event.
Spanning a page break in a RichTextContentControl.
See Also
Tasks
How to: Add Content Controls to Word Documents
How to: Protect Parts of Documents by Using Content Controls
Walkthrough: Creating a Template By Using Content Controls