I have 2 Listboxes , each are on different tab page
listBox1 with items A,B,C and listBox2 with exactly same items A,B,C
When I select Item A from listBox1, I want Item A from listBox2 selected aswell and vice versa
I use this code :
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox1.SelectedItem.ToString();
int index = listBox2_Fichiers.FindString(item);
listBox2.SetSelected(index, true);
}
private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
string item = listBox2.SelectedItem.ToString();
int index = listBox1_Fichiers.FindString(item);
listBox1.SetSelected(index, true);
}
It works only in one way, from 1 to 2 or from 2 to 1 , but when I try to activate both I get this exception: System.StackOverflowException
What am I missing ?
listBox1_SelectedIndexChanged
will calllistBox2_SelectedIndexChanged
and vice-versa. – smoksnes