Fix error while removing filter on a sorted binding list
This commit is contained in:
parent
f29dff3386
commit
4a82541ffd
2 changed files with 6 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace LibationWinForms
|
|||
public SortableBindingList1() : base(new List<T>()) { }
|
||||
public SortableBindingList1(IEnumerable<T> enumeration) : base(new List<T>(enumeration)) { }
|
||||
|
||||
protected bool SuspendSorting { get; set; }
|
||||
protected MemberComparer<T> 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))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue