急..求救..请大侠们帮帮忙..谢啦... 现在有两个下拉列表框(一左一右呈现)..有一个添加按钮...当点击添加按钮时左边列表框里的值就到右边列表框里去了..请各位给一下具体代码..必重谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); } 就是点击添加按钮时..左边框的值就到右边框里面去了啊...两个框都是下拉列表框DropDownList comboBox2.DataSource = comboBox1.DataSource;comboBox1.DataSource = null;随手打的,有错的话自己调试去。 private void button1_Click(object sender, EventArgs e) { comboBox2.Items.Add(comboBox1.SelectedItem); comboBox1.Items.Remove(comboBox1.SelectedItem); } private void button1_Click(object sender, EventArgs e) { DropDownList2.Items.Add(DropDownList1.SelectedItem); DropDownList1.Items.Remove(DropDownList1.SelectedItem); } 和两个list一样,点击后取dropdownlist1.selectitem,在再dropdownlist2中添加dropdownlist2.item.add就可以了,只不过可能需要插入前做一下判断是否dropdownlist1中的值在dropdownlist2中有重复 web控件.一样啊DropDownList1.Items.AddRange(DropDownList2.Items); comboBox1.DataSource可能需要clone一下,问题太简单了,懒得开IDE去试了。 foreach (object o in comboBox1.Items) { comboBox2.Items.Add(o); }這樣可以 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]); } } LS的不能用foreach 嗎? 代碼要少好多 protected void Button1_Click(object sender, EventArgs e) { foreach (object o in DropDownList1.Items) { DropDownList2.Items.Add(o.ToString()); } } 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楼得到的启发... 动态实例化如何实现?? HttpWebResponse 问题。 请问,正则表达式的这个"|"符号 Process.start打开EXE档传值问题 调式报错“Unable to launch the asp.net development Server” combobx 控件样式高手们帮下忙 XML出错的问题? 文本框是richtextbox,有多行文本,当选定某行文本时,单击删除按扭将其删除,该怎么样写代码? ===散分!!!因为气愤=== WPF,请问路由事件 本地exe程序如何获取其他程序中传过来的参数 高分求C#采集文章源码
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);
}
comboBox1.DataSource = null;随手打的,有错的话自己调试去。
{
comboBox2.Items.Add(comboBox1.SelectedItem);
comboBox1.Items.Remove(comboBox1.SelectedItem); }
{
DropDownList2.Items.Add(DropDownList1.SelectedItem);
DropDownList1.Items.Remove(DropDownList1.SelectedItem); }
DropDownList1.Items.AddRange(DropDownList2.Items);
foreach (object o in comboBox1.Items)
{
comboBox2.Items.Add(o);
}
這樣可以
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]);
} }
protected void Button1_Click(object sender, EventArgs e)
{
foreach (object o in DropDownList1.Items)
{
DropDownList2.Items.Add(o.ToString());
}
}
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楼得到的启发...