1.将listbox1中选中的项添加到listbox2中
protected void Button1_Click(object sender, EventArgs e) {
ListItemCollection Items = new ListItemCollection();
//获取listbox1中所有的值并进行循环遍历,若该项被选中,则添加到Items中来
foreach(ListItem item in this.ListBox1.Items)
{
if (item.Selected)
Items.Add(item);
}
for (int i = 0; i < Items.Count; i++)
{
//j将items中的值分别添加到listbox2中,并将listbox1中相应的值移除
this.ListBox2.Items.Add(Items[i]);
this.ListBox1.Items.Remove(Items[i]);
}
//将listbox2中所有项的select设置成false
this.ListBox2.ClearSelection();
}
rotected void Button2_Click(object sender, EventArgs e)
{
ListItemCollection Items = new ListItemCollec