mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-05 00:19:27 +03:00
Fixes to listview selected items
Previously SelectedIndices would continue to reference indices which no longer existed if they were removed from the list.
This commit is contained in:
parent
1d16b6e5a7
commit
25495cf77e
@ -125,13 +125,24 @@ namespace DarkUI.Controls
|
|||||||
// Find the starting index of the old item list and update anything past that
|
// Find the starting index of the old item list and update anything past that
|
||||||
if (e.OldStartingIndex < (Items.Count - 1))
|
if (e.OldStartingIndex < (Items.Count - 1))
|
||||||
{
|
{
|
||||||
for (var i = e.NewStartingIndex; i <= Items.Count - 1; i++)
|
for (var i = e.OldStartingIndex; i <= Items.Count - 1; i++)
|
||||||
{
|
{
|
||||||
UpdateItemPosition(Items[i], i);
|
UpdateItemPosition(Items[i], i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Items.Count == 0)
|
||||||
|
{
|
||||||
|
if (_selectedIndices.Count > 0)
|
||||||
|
{
|
||||||
|
_selectedIndices.Clear();
|
||||||
|
|
||||||
|
if (SelectedIndicesChanged != null)
|
||||||
|
SelectedIndicesChanged(this, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpdateContentSize();
|
UpdateContentSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,15 +236,7 @@ namespace DarkUI.Controls
|
|||||||
|
|
||||||
public int GetItemIndex(DarkListItem item)
|
public int GetItemIndex(DarkListItem item)
|
||||||
{
|
{
|
||||||
var index = -1;
|
return Items.IndexOf(item);
|
||||||
foreach (var otherItem in Items)
|
|
||||||
{
|
|
||||||
index++;
|
|
||||||
if (item == otherItem)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectItem(int index)
|
public void SelectItem(int index)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user