Wondering using listbox c#
I have looking for error on these code all day, but I really don't understand why it didn't work
private void button2_Click(object sender, EventArgs e)
{
int numberItems = listBoxMenu.Items.Count;
for(int i=0;i<numberItems;i++)
{
if (listBoxMenu.GetSelected(i))
{
listBoxChosen.Items.Add(listBoxMenu.Items[i]);
listBoxMenu.Items.RemoveAt(i);
}
}
}
These code above try to insert selected item from lisboxMenu to listBoxChosen...
I appreciate for your help