Udostępnij za pośrednictwem


Using Windows Forms Controls on Excel Worksheets

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and versions of Microsoft Office.

Project type

  • Document-level projects

Microsoft Office version

  • Excel 2003

  • Excel 2007

For more information, see Features Available by Application and Project Type.

You can add Windows Forms controls to your Microsoft Office Excel workbooks in the same manner that you add controls to Windows Forms. For general information about working with controls on documents, see Windows Forms Controls on Office Documents Overview.

Control Considerations for Excel

There are a few considerations that are specific to Excel.

Matching Control Size to Cell Size

You can set the control to be resized automatically when the size of the parent cell is changed. For more information, see How to: Resize Controls Within Worksheet Cells.

Adding Components That Are Shared by All Worksheets

You can add components that you want to share among all worksheets, such as a DataSet, to the Workbook Designer instead of to the worksheets. The component will appear on the component tray.

Formula for Embedding Controls

When you select a control in Excel, you will see =EMBED("WinForms.Control.Host","") in the Formula Bar. This text is necessary and should not be deleted.

See Also

Tasks

How to: Resize Controls Within Worksheet Cells

How to: Hide Controls on Worksheets when Printing

Walkthrough: Changing Worksheet Formatting Using CheckBox Controls

Walkthrough: Displaying Text in a Text Box in a Worksheet Using a Button

Walkthrough: Updating a Chart in a Worksheet Using Radio Buttons