Share via


Word Dynamic Controls Sample

Note

This sample runs only in Microsoft Office Word 2007.

When you do not know at design time how many controls will be required in a document at run time, you can add controls dynamically in response to events.

This sample demonstrates how to add and remove Windows Forms controls and host controls.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To run this sample

  1. Press F5.

  2. Place the insertion point in the document and then select a check box in the actions pane.

    A control is added at the insertion point.

  3. Clear the check box that you selected.

    The control is removed from the document.

Demonstrates

  • Dynamically placing Windows Forms controls and host controls at the insertion point on a document.

  • Dynamically removing Windows Forms controls and host controls from a document.

See Also

Tasks

Excel Dynamic Controls Sample

Concepts

Host Items and Host Controls Overview

Actions Pane Overview

Other Resources

Document-Level Samples

Controls on Office Documents