下面的示例演示了如何把 ChartControl 添加到窗体中。 注意,不能同时在设计时刻和运行时刻把图表控件添加到图表应用程序。

C#CopyCode image复制代码
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraCharts;
// ...

private void OnButtonClick(object sender, System.EventArgs e) {
    // Create a new Chart control.
    ChartControl chart = new ChartControl();

    // Set the chart's location.
    chart.Location = new Point(10, 10);

    // Perform any other initialization here.
    // ...
    // ...

    // Add the chart to the Form.
    this.Controls.AddRange(new Control[] {chart});
}
Visual BasicCopyCode image复制代码
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
' ...

Private Sub OnButtonClick(sender As Object, e As System.EventArgs) _
Handles Button1.Click
    ' Create a new Chart control.
    Dim chart As New ChartControl()

    ' Set the chart's location.
    chart.Location = New Point(10, 10)

    ' Perform any other initialization here.
    ' ...
    ' ...

    ' Add the chart to the Form.
    Me.Controls.AddRange(New Control() {chart})
End Sub