c#把 左边listBox1的数据全部移动到右边listBox2中的代码怎么写了。。
来源:百度知道 编辑:UC知道 时间:2024/06/19 04:43:05
楼上的两个真是浪费时间,就一句话
ListBox2.DataSource = ListBox1.Items
如果要清空ListBox1
就ListBox1.Items.clear()
WinForm的不需要DataBind()
Asp.Net的需要ListBox2.DataBind()
用个for不就出来了?
这种问题 自己想 LZ你好懒!
int count = ListBox1.Items.Count;
for (int i = 0; i < count; i++)
{
ListBox2.Items.Add(ListBox1.Items[i]);
}
//如果要求ListBox1所有项目全部清空的话,加上这句话
ListBox1.Items.Clear();
楼上的方案挺好,
我想是不是需要在设置DataSource之后,加上
ListBox2.DataBind();
?