Hello. I have 6 list boxes in a form that I need to be mutually exclusive (ie if an item in listbox1 is selected and the user switches to click on an item in listbox2, I need the listbox1 selection to be unselected, as with every other).
I have been trying some things for a while with no luck. Originally, I tried:
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(listBox2.SelectedIndex > -1){listBox2.ClearSelected(); listBox2.ClearSelected();}
if(listBox3.SelectedIndex > -1){listBox3.ClearSelected(); listBox3.ClearSelected();}
//etc. to listbox6
}
This clears the others fine but also unselects listbox1, looks like listbox1 loses control while the form clears all other boxes, and never gets it back.
I also looked to try the Leave event for a listbox, which would clear the box on exit. This does not fire, which is expected after some research.
Any ideas?
I have been trying some things for a while with no luck. Originally, I tried:
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
if(listBox2.SelectedIndex > -1){listBox2.ClearSelected(); listBox2.ClearSelected();}
if(listBox3.SelectedIndex > -1){listBox3.ClearSelected(); listBox3.ClearSelected();}
//etc. to listbox6
}
This clears the others fine but also unselects listbox1, looks like listbox1 loses control while the form clears all other boxes, and never gets it back.
I also looked to try the Leave event for a listbox, which would clear the box on exit. This does not fire, which is expected after some research.
Any ideas?