Hi all,
I have 2 listboxes with SelectionMode = MultiExtended and I just cannot
figure out why I get the error below:
System.IndexOutOfRangeException was unhandled
Message="Index was outside the bounds of the array."
Source="System.Windows.Forms"
Listbox Data:
Index String
0 A - Selected
1 B - Not Selected
2 C - Selected
private void button3_Click(object sender, EventArgs e)
{
if (lstBoxAll.SelectedIndex != -1)
{
for (int x = 0; x < lstBoxAll.Items.Count; x++)
{
if (lstBoxAll.GetSelected(x) == true)
{
// when x=2 and lstBoxAll.GetSelected(x) == true, I
still am not able to retrieve the 3rd item from my list
lstBoxSelected.Items.Add(lstBoxAll.SelectedItems[x].ToString());
}
}
//for (int counter = lstBoxAll.SelectedItems.Count - 1;
counter >= 0; counter--)
//{
//
lstBoxAll.Items.Remove(lstBoxAll.SelectedItems[counter]);
//}
}
}
Any ideas?
Thank you
Joao