Click here to Skip to main content
13,002,000 members (74,794 online)
Rate this:
Please Sign up or sign in to vote.
See more:
I need a way to automatically scroll to a selected item in a list view. For example: There are 10 items in the list view and only the first 5 are visible. A function selects the 9th item and the list view should automatically scroll to the 9th item. I tried using the following code.
listView1.Items(8).Selected = True

But it doesn't work. Please help

I've went through the code again and found out something new. It seems like the list view is actually selecting the item but it doesn't highlight the selected item in the list view and it also does not scroll to the selected item.

I tried refresh and update methods in the list view but it does not seem to be working. Please help
Posted 8-May-11 20:52pm
Updated 2-Aug-16 1:01am
SAKryukov 9-May-11 2:58am
Tag it! Forms, WPF, what?!
obhasha07 9-May-11 3:30am
sorry mate the updated answer doesn't seem to be working. I don't know what's going on. The code I have given in my question worked when I run it the first time. But after a while it doesn't work. I've debugged the application and it even goes through every line. Please help!!!
Tarun.K.S 9-May-11 6:36am
All I can say is weird!
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

In WPF, you can use ScrollIntoView.


UPDATE: After your updated question, since its a WinForms application,
I tried in this way:


Worked for me. Did it work for you?
obhasha07 9-May-11 3:03am
It's a windows forms application. So that doesn't help. But thanks anyway.
Tarun.K.S 9-May-11 3:07am
I have updated the answer.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

ListView_ProgressStatus.Items[ListView_ProgressStatus.Items.Count - 1].EnsureVisible();

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 2 Aug 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100