private void Ok_SelectedIndexChanged(object sender, EventArgs e) { int i = ((ListBox)sender).SelectedIndex; if (((Instruction)((ListBox)sender).SelectedItem) != null) { Program2.SetSelected(((Instruction)((ListBox)sender).SelectedItem).index, true); } if (i != -1) { falseNegatives.ClearSelected(); falsePositives.ClearSelected(); } //Ok.SelectedIndex = i; //Ok.SelectedIndex = i; }