private void RefreshMonsterList() { if (txtSearchMonster.Text == "") { MonsterInfoListBox.SelectedIndexChanged -= MonsterInfoListBox_SelectedIndexChanged; List <bool> selected = new List <bool>(); for (int i = 0; i < MonsterInfoListBox.Items.Count; i++) { selected.Add(MonsterInfoListBox.GetSelected(i)); } MonsterInfoListBox.Items.Clear(); for (int i = 0; i < Envir.MonsterInfoList.Count; i++) { MonsterInfoListBox.Items.Add(Envir.MonsterInfoList[i]); } for (int i = 0; i < selected.Count; i++) { MonsterInfoListBox.SetSelected(i, selected[i]); } MonsterInfoListBox.SelectedIndexChanged += MonsterInfoListBox_SelectedIndexChanged; } }
public void UpdateList() { MonsterInfoListBox.SelectedIndexChanged -= MonsterInfoListBox_SelectedIndexChanged; List <bool> selected = new List <bool>(); for (int i = 0; i < MonsterInfoListBox.Items.Count; i++) { selected.Add(MonsterInfoListBox.GetSelected(i)); } MonsterInfoListBox.Items.Clear(); for (int i = 0; i < MonsterInfoList.Count; i++) { MonsterInfoListBox.Items.Add(MonsterInfoList[i]); } for (int i = 0; i < selected.Count; i++) { MonsterInfoListBox.SetSelected(i, selected[i]); } MonsterInfoListBox.SelectedIndexChanged += MonsterInfoListBox_SelectedIndexChanged; }