[英]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.