2

I am trying to get a list scrolled at the initial point after an action whose result is the removal of all items and repopulation.

I wanted to get the scroll position recorded and then set back to it but GetScrollPos always returns 0 for some reason.

I have been looking over all the ListCtrl methods but can't seem to find a way and also noticed GetScrollPos is not there but neither does it raise an exception.

4

1 回答 1

10

我通过计算底部项目并使用EnsureVisible它上面的项目来让它工作,因为EnsureVisible如果有的话,总是在目标项目下面显示一个额外的项目。

完美运行,不需要,GetScrollPos因为我很确定没有SetScrollPos.

list_total  = list.GetItemCount()
list_top    = list.GetTopItem()
list_pp     = list.GetCountPerPage()
list_bottom = min(list_top + list_pp, list_total - 1)
list.EnsureVisible((list_bottom - 1))
于 2013-09-17T09:06:00.330 回答