By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,464 Members | 1,616 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,464 IT Pros & Developers. It's quick & easy.

ListView last fully visible item

P: n/a
Hello

i need to find out the last fully visible item of a Llistview. If it
would be a treeview then it would be easy, I'm even thinkin of faking my
treeview as listview, but maybe there is some easy way I don't see?
--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl
Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Adam,

you can find the last visible item with this (untested!) code:

ListViewItem lastVisible = listView.TopItem;

for (int i = listView.TopItem.Index + 1; i < listView.Items.Count; i++)
{
if (listView.ClientRectangle.Contains(listView.Items[i].Bounds))
{
lastVisible = listView.Items[i];
}
else
{
break;
}
}

Actually, this code is too simple: it doesn't take into account if the
horizontal scroll bar is visible or not...

HTH,
Alexander

foreach (ListViewItem item in
"Adam Klobukowski" <at***@gabo.pl> wrote in message
news:d0**********@atlantis.news.tpi.pl...
Hello

i need to find out the last fully visible item of a Llistview. If it would
be a treeview then it would be easy, I'm even thinkin of faking my
treeview as listview, but maybe there is some easy way I don't see?
--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl

Nov 16 '05 #2

P: n/a
Alexander Shirshov napisaƂ(a):
Adam,

you can find the last visible item with this (untested!) code:

ListViewItem lastVisible = listView.TopItem;

for (int i = listView.TopItem.Index + 1; i < listView.Items.Count; i++)
{
if (listView.ClientRectangle.Contains(listView.Items[i].Bounds))
{
lastVisible = listView.Items[i];
}
else
{
break;
}
}

Actually, this code is too simple: it doesn't take into account if the
horizontal scroll bar is visible or not...


Works good enough for me, thanks.

--
Semper Fidelis

Adam Klobukowski
at***@gabo.pl
Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.