How to control the scroolbar.location of ListView?

C

cyshao

How to control the scroolbar.location of ListView?

I have a ListView with many items.
I want to locate ListView scrollBar to bottom, top, or some item.

How can I do that ?

Thanks

Charles Shao
 
C

Claudio Grazioli

How to control the scroolbar.location of ListView?

I have a ListView with many items.
I want to locate ListView scrollBar to bottom, top, or some item.

How can I do that ?

You could do something like this:

Setting it to the top:
ListViewItem firstItem = _lstTest.Items[0];
firstItem.EnsureVisible();

Setting it to the bottom:
ListViewItem lastItem = _lstTest.Items[_lstTest.Items.Count - 1];
lastItem.EnsureVisible();

So the secret is "EnsureVisible()". If you have the ListViewItem just call
EnsureVisible().

hth
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top