[英]How to add/move multiselected items from one listbox to another listbox?
[英]How to add data from one listbox to another listbox?
listbox1 中显示以下数据。 我想将项目从 listbox2 传递到 listbox1。 结果应该如下图所示(lb1)。如何实现? 非常感谢您的帮助!
var itm = listBox2.Items[0].ToString();
listBox1.Items.Add(itm);
使用AddRange
方法。 试试看:
listBox1.Items.AddRange(listBox2.Items);
您可以使用AddRange
listBox1.Items.AddRange(listBox2.Items);
或者,如果您想要另一个列表框中的内容的精确副本,而不需要您的旧项目。
listBox1.Items = listBox2.Items;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.