日期:2014-05-17  浏览次数:20873 次

C# 中 MSchart的使用

在一个winform 程序中 在 Form的 load 函数中添加如下代码:


Chart c = new Chart();
c.ChartAreas.Add(new ChartArea());
c.Width = 200;
c.Height = 200;
Series mySeries = new Series();
mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 });
//mySeries.LabelAngle = 45; // why doesn't this work?
c.Series.Add(mySeries);

为什么在form中不显示chart呢????

------解决方案--------------------
想复杂了
C# code

using System.Windows.Forms.DataVisualization.Charting;
... ...
Chart c = new Chart();
ChartArea Area1 = new ChartArea();
Area1.BackColor = Color.Black;
c.ChartAreas.Add(Area1);
c.Width = 200;
c.Height = 200;
Series mySeries = new Series();
mySeries.Points.DataBindXY(new string[] { "one", "two", "three" }, new int[] { 1, 2, 3 });
// mySeries.LabelAngle = 45; // why doesn't this work?
c.Series.Add(mySeries);
[B][color=FF0033]this.controls.add(c);[color][/B]