Dela via


Chart Control

Applies to

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

Document-level projects

  • Excel 2007

  • Excel 2003

Application-level projects

  • Excel 2007

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

The Chart control is a chart object that exposes events and can be bound to data. When you add a chart to a worksheet, Visual Studio Tools for Office creates a Chart object that you can program against directly without having to traverse the Microsoft Office Excel object model.

Creating the Control

You can add Chart controls to a Microsoft Office Excel worksheet at design time or at run time in a document-level project.

Starting in Visual Studio 2008 Service Pack 1 (SP1), you can add Chart controls to a worksheet at run time in an application-level add-in. For more information, see How to: Add Chart Controls to Worksheets.

Note

Dynamically created chart objects are not persisted in the worksheet as host controls when the worksheet is closed. For more information, see Adding Controls to Office Documents at Run Time.

Binding Data to the Control

A Chart control only supports simple data binding. The Chart control should be bound to a data source using the DataBindings properties. If the data in the bound dataset is updated through any mechanism, the Chart control reflects the changes.

Formatting

All formatting that can be applied to a Chart can also be applied to a Microsoft.Office.Tools.Excel.Chart control. This includes borders, fonts, chart type, gridlines, legend, and data labels.

Events

The following events are available for the Chart control:

See Also

Tasks

Excel Add-In Dynamic Controls Sample

How to: Add Chart Controls to Worksheets

Concepts

Extending Word Documents and Excel Workbooks in Application-Level Add-ins at Run Time

Excel Application-Level Add-in Development

Adding Controls to Office Documents at Run Time

Binding Data to Controls in Office Solutions

Programmatic Limitations of Host Items and Host Controls

Other Resources

Controls on Office Documents

Excel Host Controls

Word Host Controls

Change History

Date

History

Reason

July 2008

Added information about using chart controls in an application-level add-in.

SP1 feature change.