如何在C#的WinForm中制作饼状图和柱状图
1个回答
展开全部
用Chart控件
(1)设计时,在Form1上布置一个Chart控件,2个RadioButton
(2)窗体代码Form1.cs如下
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Windows.Forms.DataVisualization.Charting;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
chart1.Series[0].Points.AddXY(1, 10);
chart1.Series[0].Points.AddXY(2, 80);
chart1.Series[0].Points.AddXY(3, 55);
chart1.Series[0].Points.AddXY(4, 70);
chart1.Series[0].Points.AddXY(5, 92);
}
private void radioButton1_CheckedChanged(
object sender,
EventArgs e)
{
if (radioButton1.Checked)
{
chart1.Series[0].ChartType = SeriesChartType.Column;
}
else
{
chart1.Series[0].ChartType = SeriesChartType.Pie;
}
}
}
}
(3)运行
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询