hi!
i take Two list boxes. and two buttons one for Add Items and another for Remove Items.
by default items is displayed in Listbox1 and i select items (one or more) and click Add items button that selected items are added into the Listbox2 . And i select items into the Listbox2, and i click Remove Items button That selected items are Removed from Listbox2.
Please Give a code for this
Thanks.
Loading
Jaish MathewsPosted Apr 17, 2010, 1:07 PM
I have only string tyes in my listbox and below code works for me
private void addButton_Click(object sender, EventArgs e)
{
//Adding to 2nd listbox
foreach (string item in listBox1.SelectedItems)
{
listBox2.Items.Add(item);
}
//Removing from 1st list box, items which added to 2nd list box
foreach (string item in listBox2.Items)
{
listBox1.Items.Remove(item);
}
}
private void button1_Click_1(object sender, EventArgs e)
{
//Adding to 1st listbox, items which selected in 2nd listbox
foreach (string item in listBox2.SelectedItems)
{
listBox1.Items.Add(item);
}
//Removing from 2nd list box, items selected
foreach (string item in listBox1.Items)
{
listBox2.Items.Remove(item);
}
}
ajay rajuPosted Apr 20, 2010, 1:55 AM