public partial class Form1 : Form { public Form1() { InitializeComponent(); List list = new List(); list.Add(new Source { ID = "1", Name = "kobe" }); list.Add(new Source { ID = "2", Name = "JORDAN" }); this.comboBox1.DisplayMember = "Name"; this.comboBox1.ValueMember = "ID"; this.comboBox1.DataSource = list;
this.comboBox2.DisplayMember = "Name"; this.comboBox2.ValueMember = "ID"; this.comboBox2.DataSource = list; } } public class Source { public string ID { get; set; } public string Name { get; set; } }
(选择后)为什么combox1变化后。。combox2跟着变化????高手请教!!!...
5 回答
幕布斯6054654
TA贡献1876条经验 获得超7个赞
因为你共用了一个变量list, this.comboBox1.DataSource = list;改成 this.comboBox1.DataSource = list.ToList();
- 5 回答
- 0 关注
- 316 浏览
添加回答
举报
0/150
提交
取消