• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 396
  • Last Modified:

Need to Save/Restore TListView workarea position

I am working with a TListView set to ownerdata, My only problem is when I update the item.count it resets the work area to the left/top most position, If possible I need to save/restore the current position so it is not lost when the item.count is updated. How can I do this?

Best Regards,
Charles
0
flashd
Asked:
flashd
1 Solution
 
EpsylonCommented:
Sorry but I can help you since the workarea does NOT reset when I update the item.count

BTW: I'm using Delphi 5
0
 
MadshiCommented:
I haven't test, if the ListView workarea really resets, but IF it does, you can use this logic to restore the position:

Before setting the new count, ask the index of the top item that is visible (LVM_GETTOPINDEX), then ask, how many items fit on one page (LVM_GETCOUNTPERPAGE).
Then to restore the position, you should make visible (LVM_ENSUREVISIBLE) two items: The top index item and this index item: "top + countPerPage - 1". Now you should have the same scroll position as before.

Regards, Madshi.

P.S: You don't need to use these windows messages (LVM_*). All these 3 functions are encapsulated by Delphi methods, I'm just not sure about the names right now...
0
 
flashdAuthor Commented:
That seems to do the trick nicely.

Thanks!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now