diff --git a/Source/LibationWinForms/grid/FilterableSortableBindingList.cs b/Source/LibationWinForms/grid/FilterableSortableBindingList.cs index e309f7fe..dcb70524 100644 --- a/Source/LibationWinForms/grid/FilterableSortableBindingList.cs +++ b/Source/LibationWinForms/grid/FilterableSortableBindingList.cs @@ -120,6 +120,8 @@ namespace LibationWinForms int visibleCount = Items.Count; + SuspendSorting = true; + foreach (var item in FilterRemoved.ToList()) { if (item.Parent is null || item.Parent.Liberate.Expanded) @@ -129,6 +131,8 @@ namespace LibationWinForms } } + SuspendSorting = false; + if (IsSortedCore) Sort(); else diff --git a/Source/LibationWinForms/grid/SortableBindingList1.cs b/Source/LibationWinForms/grid/SortableBindingList1.cs index 0a0606f5..ec545340 100644 --- a/Source/LibationWinForms/grid/SortableBindingList1.cs +++ b/Source/LibationWinForms/grid/SortableBindingList1.cs @@ -15,6 +15,7 @@ namespace LibationWinForms public SortableBindingList1() : base(new List()) { } public SortableBindingList1(IEnumerable enumeration) : base(new List(enumeration)) { } + protected bool SuspendSorting { get; set; } protected MemberComparer Comparer { get; } = new(); protected override bool SupportsSortingCore => true; protected override bool SupportsSearchingCore => true; @@ -60,7 +61,7 @@ namespace LibationWinForms protected override void OnListChanged(ListChangedEventArgs e) { - if (isSorted && + if (isSorted && !SuspendSorting && ((e.ListChangedType == ListChangedType.ItemChanged && e.PropertyDescriptor == SortPropertyCore) || e.ListChangedType == ListChangedType.ItemAdded)) {