diff --git a/Source/LibationWinForms/grid/ProductsGrid.cs b/Source/LibationWinForms/grid/ProductsGrid.cs index f42a6de1..f0fc1497 100644 --- a/Source/LibationWinForms/grid/ProductsGrid.cs +++ b/Source/LibationWinForms/grid/ProductsGrid.cs @@ -110,8 +110,8 @@ namespace LibationWinForms.grid internal void UpdateGrid(List dbBooks) { - int visibleCount = bindingList.Count; string existingFilter = syncBindingSource.Filter; + Filter(null); //Add absent books to grid, or update current books @@ -150,6 +150,11 @@ namespace LibationWinForms.grid int seriesIndex = bindingList.IndexOf(series); bindingList.Insert(seriesIndex + 1, lb); + if (series.Liberate.Expanded) + bindingList.ExpandItem(series); + else + bindingList.CollapseItem(series); + series.NotifyPropertyChanged(); } else @@ -163,13 +168,6 @@ namespace LibationWinForms.grid } } - if (bindingList.Count != visibleCount) - { - //re-filter for newly added items - Filter(null); - Filter(existingFilter); - } - // remove deleted from grid. // note: actual deletion from db must still occur via the RemoveBook feature. deleting from audible will not trigger this var removedBooks = @@ -196,8 +194,9 @@ namespace LibationWinForms.grid //no need to re-filter for removed books bindingList.Remove(removed); - if (bindingList.Count != visibleCount) - VisibleCountChanged?.Invoke(this, bindingList.LibraryBooks().Count()); + Filter(existingFilter); + + VisibleCountChanged?.Invoke(this, bindingList.LibraryBooks().Count()); } #endregion