次の方法で共有


Content Controls Sample

Download 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 noteSecurity 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

  1. Press F5.

  2. In the first row of the table, verify that you cannot edit or delete the rich text control.

  3. 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.

  4. In the third row of the table, click the icon in the picture control and browse to an image to display it.

  5. 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.

  6. 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.

  7. In the sixth row of the table, select a date in the date picker control.

  8. 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.

  9. 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:

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

Concepts

Content Controls

Other Resources

Document-Level Samples