Use the following code if you want to select on
ListBox2
the item
having the same index of the selected one of
ListBox1
.
private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
{
int cursel = listBox1.SelectedIndex;
if ( cursel < ListBox2.Items.Count )
{
ListBox2.SetSelected(cursel, true);
}
}