I have a listbox control on winform and same is Single Items SelectionMode OR One Items Selection Mode. I am trying to scroll it from form_KeyDown Event as below
if ((Keys)e.KeyCode == Keys.Down)
{
if (listBox2.Items.Count >= listBox2.SelectedIndex)
{
listBox2.SelectedIndex++;
}
}
But it’s throw an error like “ArgumentOutOfRangeException was unhandled”
Invalid argument of value =23 is not valid for selection index.
How to get ridoff?
Try this:
Remember that if you have 23 items,
SelectedIndexgoes from 0 to 22…