I have 2 Listboxes say ListBox1 and ListBox2. After unzipping the folder the files are listed in the ListBox1 . Then the user can select multiple files using ctrl button and then click on Add button whereby the users can transfer the selected files to ListBox2 .
How can i do that ?


cya
Rohan

YAAA ...i got the solution..
Thanks a lot...

here goes the code:

private void cmdadd_Click(object sender, EventArgs e)
        {
            for (int i = 0; i <= listBox1.SelectedItems.Count - 1; i++)
            {
                listBox2.Items.Add(listBox1.SelectedItems[i]);
            }
}

CYA
Rohan

You're welcome.
You can also use foreach cycle:

foreach(string item in listBox1.SelectedItems)
{
    listBox2.Items.Add(item);
}

Here is an example to move multiple selected items from one listbox to another and remove added items (c#):

// Set your listbox SelectionMode property to MultiExtended

try{
foreach(string st in listbox1.SelectedItems)
{
 listbox2.Items.Add(st);
}
// Remove the listbox2 added items from listbox1
for(int i=listbox1.Items.Count;i>0;i--)
{
 listbox1.Items.RemoveAt(listbox1.SelectedIndex);
}
}
catch
{}

This would work fine.

This question has already been answered. Start a new discussion instead.