共用方式為


Titles in Chart Controls

Titles are stored as Title objects in the Chart.Titles collection property. You can dock a title to a chart area. To do this, set the Title.DockedToChartArea property to the name of the chart area to which you want to dock the title.

Adding Titles at Run Time

The following code demonstrates how to add a title to a Chart control at run time.

Chart1.Titles.Add("NewTitle")
Chart1.Titles("NewTitle").Text = "My Chart"
Chart1.Titles("NewTitle").DockedToChartArea = Nothing
Chart1.Titles.Add("NewTitle");
Chart1.Titles["NewTitle"].Text = "My Chart";
Chart1.Titles["NewTitle"].DockedToChartArea = null;

Use properties in a Title object to customize the look and feel of the title, such as Docking, Alignment, IsDockedInsideChartArea, Position, and Font.

When using the Title.Text property to specify a legend title, use "\n" to indicate a new line.

See Also

Reference

System.Windows.Forms.DataVisualization.Charting

System.Web.UI.DataVisualization.Charting