I have 2 list boxes and want to be able to copy selected items from one to the other how ever many times I want. Ive managed to do this but I have buttons on the 2nd list box that allow me to go up and down..Now when theres to items in the second list box that are the same (e.g "gills" and "gills") it doesnt behave normally and crashes.
Is there a way in which I can get them to act as seperate items in the 2nd listbox?
code
private void buttonUp_Click(object sender, EventArgs e)
{
object selected = listBox2.SelectedItem;
int index = list2.Items.IndexOf(selected);
listBox2.Items.Remove(selected);
listBox2.Items.Insert(index - 1, selected);
listBox2.SetSelected(index - 1, true);
}
private void buttonAdd_Click(object sender, EventArgs e)
{
DataRowView selected = (DataRowView)listBox1.SelectedItem;
string item = selected["title"].ToString();
listBox2.Items.Add(item);
}
It works fine when i havnt got duplicates but when i do they just jump around randomly when i press up/down.
(ive not included down as its pretty much the same as up)