diff --git a/Source/LibationWinForms/GridView/GridEntryBindingList.cs b/Source/LibationWinForms/GridView/GridEntryBindingList.cs index b5ee0f8f..58be850c 100644 --- a/Source/LibationWinForms/GridView/GridEntryBindingList.cs +++ b/Source/LibationWinForms/GridView/GridEntryBindingList.cs @@ -30,6 +30,9 @@ namespace LibationWinForms.GridView public bool SupportsFiltering => true; public string Filter { get => FilterString; set => ApplyFilter(value); } + /// When true, itms will not be checked filtered by search criteria on item changed + public bool SuspendFilteringOnUpdate { get; set; } + protected MemberComparer Comparer { get; } = new(); protected override bool SupportsSortingCore => true; protected override bool SupportsSearchingCore => true; @@ -195,7 +198,7 @@ namespace LibationWinForms.GridView { if (e.ListChangedType == ListChangedType.ItemChanged) { - if (Items[e.NewIndex] is LibraryBookEntry lbItem) + if (FilterString is not null && !SuspendFilteringOnUpdate && Items[e.NewIndex] is LibraryBookEntry lbItem) { SearchResults = SearchEngineCommands.Search(FilterString); if (!SearchResults.Docs.Any(d => d.ProductId == lbItem.AudibleProductId)) diff --git a/Source/LibationWinForms/GridView/LibraryBookEntry.cs b/Source/LibationWinForms/GridView/LibraryBookEntry.cs index 6a312ea1..848c9e4f 100644 --- a/Source/LibationWinForms/GridView/LibraryBookEntry.cs +++ b/Source/LibationWinForms/GridView/LibraryBookEntry.cs @@ -63,7 +63,11 @@ namespace LibationWinForms.GridView } #endregion - public LibraryBookEntry(LibraryBook libraryBook) => setLibraryBook(libraryBook); + public LibraryBookEntry(LibraryBook libraryBook) + { + setLibraryBook(libraryBook); + LoadCover(); + } public SeriesEntry Parent { get; init; } public void UpdateLibraryBook(LibraryBook libraryBook) @@ -78,9 +82,9 @@ namespace LibationWinForms.GridView private void setLibraryBook(LibraryBook libraryBook) { - LibraryBook = libraryBook; + LibraryBook = libraryBook; - LoadCover(); + UserDefinedItem.ItemChanged -= UserDefinedItem_ItemChanged; // Immutable properties { diff --git a/Source/LibationWinForms/GridView/ProductsGrid.cs b/Source/LibationWinForms/GridView/ProductsGrid.cs index a715eb8e..99c52788 100644 --- a/Source/LibationWinForms/GridView/ProductsGrid.cs +++ b/Source/LibationWinForms/GridView/ProductsGrid.cs @@ -105,6 +105,8 @@ namespace LibationWinForms.GridView string existingFilter = syncBindingSource.Filter; Filter(null); + bindingList.SuspendFilteringOnUpdate = true; + //Add absent books to grid, or update current books var allItmes = bindingList.AllItems().LibraryBooks(); @@ -157,6 +159,8 @@ namespace LibationWinForms.GridView } } + bindingList.SuspendFilteringOnUpdate = false; + //Re-filter after updating existing / adding new books to capture any changes Filter(existingFilter);