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

Last Visible Item in a ListView

I'm trying to get the last visibile item in a listview, you can easly get the top item with
the .topItem property. How do you get the last visible item? Thank you
0
modified_
Asked:
modified_
  • 2
  • 2
  • 2
  • +1
1 Solution
 
malharoneCommented:
be more specific about the item of "last visibility"
give an example.
0
 
modified_Author Commented:
ok, for example if you have 100 total items in your list, but the listview window is small
and you're scrolled somewhere in the middle of the list. Say the top showing item in the
listview is at index 25, you can get this item by using ListView1.topItem. Now say the last
visible item in the scroll is at index 35, how would you get that item through programming? So you know what range of elements are currently displayed on the screen.
0
 
durkinCommented:
You could try using the .GetItemAt() method of the listview. Just work out where the bottom of your listview is (using height, top etc. properties) and pass this postion to the above method and it returns the listviewitem there. If there is nothing there then the last item in your list must also be the last visible.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
DabasCommented:
Hi modified_,
As you say yourself, ListView1.topitem gives you the item that appears at the top
ListView1.Height gives you the height of the control.
The only factor that you still need to know is the height of the ListView items.
This can be found using: ListView1.Items(0).GetBounds(ItemBoundsPortion.ItemOnly).Height)
You can now divide the height of the ListView by the height of the Items to know how many items are visible.


Dabas
0
 
durkinCommented:
Dabas, I think both you and I are presuming that modified_'s listview is in details view. Is this correct?
0
 
DabasCommented:
durkin,
Yes, you are right, I am presuming the listview is in details view.
As far as I remember, I only use details view, and am sorry Microsoft did not set it as the default view!
From modified's second post, I tend to believe that he also is implying details view.

Now if it is NOT details view, then ListView1.Items(0).GetBounds(ItemBoundsPortion.ItemOnly).Width) will allow you to figure out how many items are being shown per row too


Dabas
0
 
modified_Author Commented:
Thanks Thats i was i was trying to figure out, i was working on how to get the syntax to do that Dabas. And yes i did mean detail view. Thanks
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now