现在有两个下拉列表框(一左一右呈现)..有一个添加按钮...当点击添加按钮时左边列表框里的值就到右边列表框里去了..请各位给一下具体代码..必重谢

解决方案 »

  1.   

               ComboBox c=new ComboBox();
    c.Items.Add(1);
    c.Items.Add(2);
    c.Items.Add(3);
                ComboBox c1=new ComboBox();
    c1.Items.Add(4);
    c1.Items.Add(5);
    c1.Items.Add(6);
                foreach(object ob in c.Items)
                {
                    c1.Items.Add(ob);
                }
      

  2.   

    就是点击添加按钮时..左边框的值就到右边框里面去了啊...两个框都是下拉列表框DropDownList
      

  3.   

    comboBox2.DataSource = comboBox1.DataSource;
    comboBox1.DataSource = null;随手打的,有错的话自己调试去。
      

  4.   

     private void button1_Click(object sender, EventArgs e)
            {
                comboBox2.Items.Add(comboBox1.SelectedItem);
                comboBox1.Items.Remove(comboBox1.SelectedItem);        }
      

  5.   

    private void button1_Click(object sender, EventArgs e) 
            { 
                DropDownList2.Items.Add(DropDownList1.SelectedItem); 
                DropDownList1.Items.Remove(DropDownList1.SelectedItem);         }
      

  6.   

    和两个list一样,点击后取dropdownlist1.selectitem,在再dropdownlist2中添加dropdownlist2.item.add就可以了,只不过可能需要插入前做一下判断是否dropdownlist1中的值在dropdownlist2中有重复
      

  7.   

    web控件.一样啊
    DropDownList1.Items.AddRange(DropDownList2.Items);
      

  8.   

    comboBox1.DataSource可能需要clone一下,问题太简单了,懒得开IDE去试了。
      

  9.   


                foreach (object o in comboBox1.Items)
                {
                    comboBox2.Items.Add(o);
                }
    這樣可以
      

  10.   


    private void Button1_Click(object sender, System.EventArgs e)
    {
    for(int i=0;i<this.DropDownList1.Items.Count;i++)
    {
                   this.DropDownList2.Items.Add(this.DropDownList1.Items[i]);
    } }
      

  11.   

    LS的不能用foreach 嗎? 代碼要少好多
      

  12.   


        protected void Button1_Click(object sender, EventArgs e)
        {
            foreach (object o in DropDownList1.Items)
            {
                DropDownList2.Items.Add(o.ToString());
            }
        }
      

  13.   


                ListItem item = new ListItem();
                item.Text = dropCity.SelectedItem.Text;
                item.Value = dropCity.SelectedItem.Value;
                dropNothing.Items.Add(item);            ListItem item = new ListItem();
                item.Text = dropNothing.SelectedItem.Text;
                item.Value=dropNothing.SelectedItem.Value;
                dropNothing.Items.Remove(item);最后的具体实现的代码..看到13楼得到的启发...