【发布时间】:2016-05-18 11:37:07
【问题描述】:
我有以下问题:
拥有具有多个属性的对象列表(MyClass 类)我想将图表数据源绑定到特定的类属性:
public class myClass {
public int a;
public int t;
public double v;
myClass(int aa, int tt, double val){
a=aa;
t=tt;
v=val;
}
}
public List<myClass> myList;
myList.Add(new myClass(1,1,10));
myList.Add(new myClass(1,2,15));
myList.Add(new myClass(2,3,20));
我现在想得到一个图表,其中 t 映射到 AxisX,v 映射到 AxisY。 我能够从对象列表中获取 2 个数组,但我不知道如何将它们“绑定”到数据源:
myList(item => item.t).ToArray()
myList(item => item.v).ToArray()
// Create data binding for chart
var bs = new BindingSource();
bs.DataSource = ????????????????;
感谢您的帮助!!
R.
【问题讨论】:
-
查看链接的帖子了解如何对图表进行数据绑定。短版:不要绑定图表,要绑定系列!
标签: c# arrays data-binding charts