I need to create an UI which allows me to select entries from one list
box and add it to another listbox at the run time. Now, the listbox1 may
contain combo box and checkbox as the items.
For example, if I add a combo box labelled Quarter with values "Q1,
Q2, Q3, Q4" as an item in listbox1 and select the entry Q1 in it, and
click on the "Add" button, it should be added to listbox2. Vice versa
should also be possible. This should be possible at the run time. How
could I add combo box and checkbox as an item to the listbox? Also,
please suggest if for the add-remove buttons, the code I've is correct. Please look into the attachment for the UI which would help to understand this better.
private void MoveListBoxItems(ListBox source, ListBox destination)
{
ListBox.SelectedObjectCollection sourceItems = source.SelectedItems;
foreach (var item in sourceItems)
{
destination.Items.Add(item);
}
while (source.SelectedItems.Count > 0)
{
source.Items.Remove(source.SelectedItems[0]);
}
}
private void button1_Click(object sender, EventArgs e)
{
MoveListBoxItems(listBox1, listBox2);
}
private void button2_Click(object sender, EventArgs e)
{
MoveListBoxItems(listBox2, listBox1);
}