以下的例子展示了如何将ChartControl添加到Windows窗体应用程序中。注意图表控件可以在设计时和运行时添加到你的图表应用程序中。
设计时
默认状态下, ChartControl项被添加进VS IDE的DX.12.1:Data工具箱选项卡中。就这样,简单地拖拽相应的工具箱项目,把它放置于窗体应上就可以把图表控件加到你的项目中。
注意:当添加ChartControl时,会调用到图表向导窗口。如果你不想用到它点击“取消”,或者按照软件的步骤来定制你的图表的初始轮廓。
运行时
运行时添加一个图表控件到窗体,不要忘了把所有必需的组件添加到你项目中的参考列表中。
C#
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});
}
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});
}
VB
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
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
本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/328.html
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/328.html