如何使用按钮将所有项目从一个列表框移动到另一个列表框 [英] how can i move all the items from one listbox to another wih a use of a button
本文介绍了如何使用按钮将所有项目从一个列表框移动到另一个列表框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我如何将一个列表框中的所有项目移动到另一个列表框
解决方案
试试这个..
On Button点击..
ListBox2.Items.Clear();
foreach (ListItem item in ListBox1.Items)
{
ListBox2.Items.Add(项目);
}
希望有帮助..
更简单:
listbox2.Items.AddRange(listbox1.Items.ToArray());
编辑========================
< pre lang =c#> listbox2.Items.AddRange(listbox1.Items.ToArray());
这里的教训是通过这种事情成为程序员和肌肉......
试试这个
私有 Sub Button1_Click(发件人作为系统。对象,e 作为 System.EventArgs)句柄 Button1.Click
' 仅在您要清除项目时取消注释以下此行
' 来自ListBox1之前从ListBox2添加项目
' ListBox1.Items.Clear()
ListBox1.Items.AddRange(ListBox2.Items)
结束 Sub
can someone tell me how can i move all the items fro one listbox to another listbox
解决方案
try this..
On Button Click..
ListBox2.Items.Clear(); foreach(ListItem item in ListBox1.Items) { ListBox2.Items.Add(item); }
hope it helps..
Even easier:
listbox2.Items.AddRange(listbox1.Items.ToArray());
EDIT ========================
listbox2.Items.AddRange(listbox1.Items.ToArray());
The lesson here is "be a programmer and muscle through this kind of thing..."
Try this
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click 'uncomment this line below only if you want to clear the items 'from ListBox1 before adding the items from ListBox2 'ListBox1.Items.Clear() ListBox1.Items.AddRange(ListBox2.Items) End Sub
这篇关于如何使用按钮将所有项目从一个列表框移动到另一个列表框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文