I'm trying to get the selected items in the order they were selected, the problem occurs when I select items in ASC order, I mean from the top to the bottom, it always return the first selectedIndex or value, and the problem is that items can be selected in any order. The ListBox control has SelectionMode set to MultiSimple, and I've tryied with MultiExtended with no success. Curiously when I select the items in reverse order from the bottom to the top it works perfectly. I've been testing, reading and searching everywhere but without getting it working, so far. The ListBox is bounded to a dataSource.
Working directly with the collection is ok cuz it returns the selectedItems, but I can't get items in the order they were selected.
private void lstEquipos_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstEquipos.SelectedIndex != -1)
{
textBox1.Text = lstEquipos.SelectedIndex.ToString();
}
}
}
Try using
SelectedItem
instead: