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);
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.