Fix error while removing filter on a sorted binding list
This commit is contained in:
parent
f29dff3386
commit
4a82541ffd
@ -120,6 +120,8 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
int visibleCount = Items.Count;
|
int visibleCount = Items.Count;
|
||||||
|
|
||||||
|
SuspendSorting = true;
|
||||||
|
|
||||||
foreach (var item in FilterRemoved.ToList())
|
foreach (var item in FilterRemoved.ToList())
|
||||||
{
|
{
|
||||||
if (item.Parent is null || item.Parent.Liberate.Expanded)
|
if (item.Parent is null || item.Parent.Liberate.Expanded)
|
||||||
@ -129,6 +131,8 @@ namespace LibationWinForms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SuspendSorting = false;
|
||||||
|
|
||||||
if (IsSortedCore)
|
if (IsSortedCore)
|
||||||
Sort();
|
Sort();
|
||||||
else
|
else
|
||||||
|
|||||||
@ -15,6 +15,7 @@ namespace LibationWinForms
|
|||||||
public SortableBindingList1() : base(new List<T>()) { }
|
public SortableBindingList1() : base(new List<T>()) { }
|
||||||
public SortableBindingList1(IEnumerable<T> enumeration) : base(new List<T>(enumeration)) { }
|
public SortableBindingList1(IEnumerable<T> enumeration) : base(new List<T>(enumeration)) { }
|
||||||
|
|
||||||
|
protected bool SuspendSorting { get; set; }
|
||||||
protected MemberComparer<T> Comparer { get; } = new();
|
protected MemberComparer<T> Comparer { get; } = new();
|
||||||
protected override bool SupportsSortingCore => true;
|
protected override bool SupportsSortingCore => true;
|
||||||
protected override bool SupportsSearchingCore => true;
|
protected override bool SupportsSearchingCore => true;
|
||||||
@ -60,7 +61,7 @@ namespace LibationWinForms
|
|||||||
|
|
||||||
protected override void OnListChanged(ListChangedEventArgs e)
|
protected override void OnListChanged(ListChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (isSorted &&
|
if (isSorted && !SuspendSorting &&
|
||||||
((e.ListChangedType == ListChangedType.ItemChanged && e.PropertyDescriptor == SortPropertyCore) ||
|
((e.ListChangedType == ListChangedType.ItemChanged && e.PropertyDescriptor == SortPropertyCore) ||
|
||||||
e.ListChangedType == ListChangedType.ItemAdded))
|
e.ListChangedType == ListChangedType.ItemAdded))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user