comboBox的问题,请帮忙解答,谢谢 本帖最后由 ivanl 于 2012-12-08 13:12:53 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 IList tList =null; tList = new List<ComboxItem> { new ComboxItem{ Name= "0", value = "--请选择--" }, new ComboxItem{ Name= "1", value = "方案1" }, new ComboxItem{ Name= "2", value = "方案2" } }; comboBox1.DataSource = tList; comboBox1.DisplayMember = "value"; comboBox1.ValueMember = "Name"; 我将代码更改为下面的就可以正确运行了,请看红色部分为更改的部分,也就是每次添加前都要new 一次discountclass,请高手解释为什么会这样呢?private void Form1_Load(object sender, EventArgs e) { comboBox1.DisplayMember = "Name"; comboBox1.ValueMember = "Value"; discountclass dc; dc = new discountclass(); dc.discounttype = "折扣A"; dc.discount = 0; comboBox1.Items.Add(new ComboxItem("方案1", dc)); dc = new discountclass(); dc.discounttype = "折扣B"; dc.discount = 1; comboBox1.Items.Add(new ComboxItem("方案2", dc)); } MS SQL SERVER2005插入汉字变成问号 如何解决Form1窗口Shown()事件关闭窗体闪屏问题? 提问WaitOne 政则表达式验证日期 水晶报表打印问题 请问怎样取得当前上网 被动态配的网络IP地址? dataGirdview中的为何不能用列名只能用列的序号 dt.Rows[][]中输出的数据为什么变了? 新手问最简单的问题 在c#环境下能用objectarx对autocad进行二次开发吗? 写了个udp小程序,但貌似只能在局域网生效,求解答 C#2012连接SQL server2008设计机票预订系统
new ComboxItem{ Name= "0", value = "--请选择--" },
new ComboxItem{ Name= "1", value = "方案1" },
new ComboxItem{ Name= "2", value = "方案2" }
};
comboBox1.DataSource = tList;
comboBox1.DisplayMember = "value";
comboBox1.ValueMember = "Name";
{
comboBox1.DisplayMember = "Name";
comboBox1.ValueMember = "Value";
discountclass dc; dc = new discountclass();
dc.discounttype = "折扣A";
dc.discount = 0; comboBox1.Items.Add(new ComboxItem("方案1", dc)); dc = new discountclass();
dc.discounttype = "折扣B";
dc.discount = 1; comboBox1.Items.Add(new ComboxItem("方案2", dc));
}