I m using VS2010 with SQL server 2008 at the backend. I m creating a windows application in which I have 2 listboxes.the data is being retrieved from SQL server database in listbox1.i want to select all itms from this listbox1 and add them to listbox2. And remove itms from this listbox2 and add them to listbox1.

listBox1.Items.Clear(); // for removing all items

   foreach(ListItem listItem in listBox1.Items) /* adding items to another listbox*/
       if (listItem.Selected == True)

Edited 2 Years Ago by castajiz_2: swfas

What would be wrong, to first copy Listbox2 to Listbox1 and then fetch data from DB to Listbox2?

//adding all items from listbox1 to listbox2
            foreach (string temp in listBox1.Items)

//after you removed data, the below code will help you to regenarate the listbox1
            foreach (string temp in listBox2.Items)
This question has already been answered. Start a new discussion instead.