DevExpress控件使用交流,DevExpress中国社区Dev联系电话 联系电话:023-68661681

DevExpress XtraCharts示例一:向Windows Forms应用程序中添加图表

来源:本站原创   发布时间:2012-09-17   浏览:3711次

本示例主要演示了如何将ChartControl添加到Windows窗体中。注意,无论你是在设计时还是在运行时均可以将图表控件添加到您的图表应用程序中。

设计时

在默认情况下,ChartControl项目将被添加到的VS IDE下的DX.12.1: Data 工具箱选项卡。因此,若要将图表控件添加到您的项目中,你只需要拖动相应的工具箱项目,然后将其放置到窗体上。

DevExpress,XtraCharts,示例,ChartControl控件,图表,Windows窗体

运行时

若要在运行时将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});
}
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

本站文章除注明转载外,均为本站原创或翻译
欢迎任何形式的转载,但请务必注明出处,尊重他人劳动成果
转载请注明:文章转载自:DevExpress控件中文网 [https://www.devexpresscn.com/]
本文地址:https://www.devexpresscn.com/post/343.html
在线
客服
微信
QQ 电话
023-68661681
返回
顶部