So the following code has the obvious error that when the user changes the selection between the two listboxes they are both cleared. What is the best way to select an item in listbox2 whilst simultaneously unselecting the item in listbox1 visa versa.
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
listbox2.ClearSelected()
}
private void listBox2_SelectedIndexChanged(object sender, System.EventArgs e)
{
listbox1.ClearSelected()
}
I would love to claim just asking for a friend but I can't seem to figure this simple one out...
For clarification the code does work when I select an item from listbox1, listbox2 is then unselected. The problem is that listbox2 is changed immediately unselecting the item from listbox1 that was just clicked
Modify both functions as follows:
bChanging
is a member of the form.This or a similar construct should work.