public IEnumerator <object> RefreshList() { using (new ControlWaitCursor(this)) { int oldSelectedType = -1; if (Types.SelectedItem is TypeEntry) { oldSelectedType = (Types.SelectedItem as TypeEntry).TypeID; } Types.BeginUpdate(); Types.Items.Clear(); Types.Sorted = false; OKButton.Enabled = false; string sql; object[] args; if (Groups.SelectedItem is GroupEntry) { var group = Groups.SelectedItem as GroupEntry; sql = "SELECT groupID, typeID, name FROM evedata.types WHERE groupID = ?"; args = new object[] { group.ID }; } else { sql = "SELECT groupID, typeID, name FROM evedata.types WHERE categoryID = ?"; args = new object[] { CategoryFilter }; } using (var q = Program.Database.BuildQuery(sql)) using (var e = q.Execute <TypeEntry>(args)) while (!e.Disposed) { yield return(e.Fetch()); foreach (var item in e) { Types.Items.Add(item); if (item.TypeID == oldSelectedType) { Types.SelectedItem = item; } } } Types.Sorted = true; Types.EndUpdate(); } }