Solved

Last Visible Item in a ListView

Posted on 2003-11-20
7
480 Views
Last Modified: 2008-03-10
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
Comment
Question by:modified_
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 9

Expert Comment

by:malharone
ID: 9791967
be more specific about the item of "last visibility"
give an example.
0
 

Author Comment

by:modified_
ID: 9793017
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
 

Expert Comment

by:durkin
ID: 9793106
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 27

Accepted Solution

by:
Dabas earned 125 total points
ID: 9794546
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
 

Expert Comment

by:durkin
ID: 9794620
Dabas, I think both you and I are presuming that modified_'s listview is in details view. Is this correct?
0
 
LVL 27

Expert Comment

by:Dabas
ID: 9794709
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
 

Author Comment

by:modified_
ID: 9797698
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 run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
.NET Error 7 42
Default parameter problem in C# 3 27
Get String split 5 33
index Out OF Range Exception error 4 32
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now