private void populateButton_Click(object sender, EventArgs e) { var location = TileLocation.Invalid; var index = listBox.SelectedIndex; if (listBox.SelectedIndex > -1) { location = _owner.Level.MonsterLocations[index]; } _owner.PopulateMonsters(); if (location != TileLocation.Invalid) { listBox.SelectedIndex = _owner.Level.MonsterLocations.IndexOf(location); } listBox.EndUpdate(); UpdateTitle(); }