直接上码了,就是comboBox1想绑定class Pattern中的 ID 显示comboBox1的可选中 。
新手自学,实在弄不清头绪。
public class Pattern
{
private int id;
private string time;
private string light;
public Pattern(int ID, String Time, String Light)
{
this.id = ID;
this.time = Time;
this.light = Light;
}
public int ID
{
get { return id; }
}
public String Time
{
get { return time; }
}
public String Light
{
get { return light; }
}
}
private void Form2_Load(object sender, EventArgs e)
{
List<Pattern> pattern = new List<Pattern>();
Pattern p1 = new Pattern(2, "12:03", "200");
Pattern p2 = new Pattern(3, "13:00", "190");
Pattern p3 = new Pattern(1, "24:09", "210");
pattern.Add(p1);
pattern.Add(p2);
pattern.Add(p3);
comboBox1.DataSource = pattern;
comboBox1.DisplayMember = "ID";
comboBox1.ValueMember = "ID";
}
------解决思路----------------------
没有问题,可以显示啊
查看是否有别的代码又去修改comboBox1了