Excel Dynamic Controls Sample
This sample runs only in Microsoft Office Excel 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.
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
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.
Clear the check box that you selected.
The control is removed from the document.
Dynamically placing Windows Forms controls and host controls at the insertion point on an Excel worksheet.
Dynamically removing Windows Forms controls and host controls from an Excel worksheet.