Set Scroll position for listview

M

moondaddy

I'm working in vb.net vs 2003 and have a listview control who's list is
longer than the area available. I know how to find an item in the
listview's list and select it so its the active item , but I don't know how
to scroll the list to this item is viewable in the list when its located
toward the bottom of the list below the viewable area. I know in some 3rd
party controls there's often a property you can set like topitemindex or
something where you can specify the index of the item that should be
scrolled to the top viewable row in the list. how can I do this with ms
listview control?
 
Y

Ying-Shen Yu[MSFT]

Hi moondaddy,
I agree with AlexS, the method EnsureVisible method will make item on the
specified
index visible. However, I'd like to make it clear this method will not
promise to make the selected item to be the top item in the listview. In my
opinion we couldn't make every item be the top item in the listview, such
as the last item in the listview.
Here is an work around to make most item selection to be the top item,
but it has no effect on the last "page" of listview, since it has no item
to scroll down.
<code>
int sel = 25;//your selected index
listView1.EnsureVisible(listView1.Items.Count -1);//scroll down to the
bottom first.
listView1.Items[sel].Selected = true;
listView1.EnsureVisible (sel);
</code>
If you still have problem on this issue, please let me know.


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
You should not reply this mail directly, "Online" should be removed before
sending, Thanks!

--------------------
| From: "moondaddy" <[email protected]>
| Subject: Set Scroll position for listview
| Date: Mon, 27 Oct 2003 15:35:06 -0600
| Lines: 14
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| NNTP-Posting-Host: adsl-66-137-119-102.dsl.hstntx.swbell.net
66.137.119.102
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:55325
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I'm working in vb.net vs 2003 and have a listview control who's list is
| longer than the area available. I know how to find an item in the
| listview's list and select it so its the active item , but I don't know
how
| to scroll the list to this item is viewable in the list when its located
| toward the bottom of the list below the viewable area. I know in some 3rd
| party controls there's often a property you can set like topitemindex or
| something where you can specify the index of the item that should be
| scrolled to the top viewable row in the list. how can I do this with ms
| listview control?
|
| --
| (e-mail address removed)
|
|
|
 

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