本帖最后由 ivanl 于 2012-12-08 13:12:53 编辑

解决方案 »

  1.   

    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";
      

  2.   

    我将代码更改为下面的就可以正确运行了,请看红色部分为更改的部分,也就是每次添加前都要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));
                        }