views:

438

answers:

1

Sorted the listview and tried to "refresh" it by selecting the first element and thus putting the scroll position at the top but it's not quite working. Here's my code:

if(lv_sets.SelectedItems.Count > 0)
{
    lv_sets.SelectedItems[0].Selected = false;
}

if (columnSorter.SortingOrder == SortOrder.Ascending) 
{
    columnSorter.SortingOrder = SortOrder.Descending;
    lv_sets.Sort();
}
else
{
    columnSorter.SortingOrder = SortOrder.Ascending;
    lv_sets.Sort();
}

lv_sets.Items[0].Selected = true; //This selects the item but it doesn't move the scrollbar to the top. Why?

Thanks for any help!

+4  A: 
lv_sets.Items[0].EnsureVisible()
John Fisher
Thanks! That worked.
Chris