简体   繁体   中英

How to add data from one listbox to another listbox?

The following data are displayed in listbox1. I want to pass items from listbox2 to listbox1. The result should be look as shown below (lb1).How can this be achieved? Many thanks for your help!

var itm = listBox2.Items[0].ToString();
          listBox1.Items.Add(itm);

enter image description here

Use AddRange Method. Try like:

listBox1.Items.AddRange(listBox2.Items);

You can use AddRange

listBox1.Items.AddRange(listBox2.Items);

Or if you want an exact copy of what is in the other listbox without your old items.

listBox1.Items = listBox2.Items;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM