473,418 Members | 2,340 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

ListView Scrolling not following SelectedItem?

I have a long list of Items in a ListView... if I scroll down to something
that is not visible without scrolling and then click on it I open another
window where you can work with the details of that item..
Then I close that window I repopulate the ListView to reflect some changes
make in the details window.. and I re-set the selected Row after the
population of the ListView so the item I was working on is selected again..
but then the scroll is at the top..

How do I make the scroll set so that the selected Item is within the visible
part?

(I have set the Multiselect to false so there can be only one selected)

/Lars Netzel
Nov 23 '05 #1
4 9029
Call the EnsureVisible method of the ListViewItem you want to make visible:
ListView1.Items(N).EnsureVisible

When N is the Index of the Item you want.

"Lars Netzel" wrote:
I have a long list of Items in a ListView... if I scroll down to something
that is not visible without scrolling and then click on it I open another
window where you can work with the details of that item..
Then I close that window I repopulate the ListView to reflect some changes
make in the details window.. and I re-set the selected Row after the
population of the ListView so the item I was working on is selected again..
but then the scroll is at the top..

How do I make the scroll set so that the selected Item is within the visible
part?

(I have set the Multiselect to false so there can be only one selected)

/Lars Netzel

Nov 23 '05 #2
Use EnsureVisible method

"Lars Netzel" <ui****@adf.se> wrote in message
news:eE**************@TK2MSFTNGP14.phx.gbl...
I have a long list of Items in a ListView... if I scroll down to something
that is not visible without scrolling and then click on it I open another
window where you can work with the details of that item..
Then I close that window I repopulate the ListView to reflect some changes
make in the details window.. and I re-set the selected Row after the
population of the ListView so the item I was working on is selected
again.. but then the scroll is at the top..

How do I make the scroll set so that the selected Item is within the
visible part?

(I have set the Multiselect to false so there can be only one selected)

/Lars Netzel

Nov 23 '05 #3
Found it....

http://msdn.microsoft.com/library/de...l/listview.asp

Use eg- Item(42).EnsureVisible()

/lars
"Lars Netzel" <ui****@adf.se> wrote in message
news:eE**************@TK2MSFTNGP14.phx.gbl...
I have a long list of Items in a ListView... if I scroll down to something
that is not visible without scrolling and then click on it I open another
window where you can work with the details of that item..
Then I close that window I repopulate the ListView to reflect some changes
make in the details window.. and I re-set the selected Row after the
population of the ListView so the item I was working on is selected
again.. but then the scroll is at the top..

How do I make the scroll set so that the selected Item is within the
visible part?

(I have set the Multiselect to false so there can be only one selected)

/Lars Netzel

Nov 23 '05 #4
My client didn't update so I saw your replies.. thank you..
"Simon" <Si***@discussions.microsoft.com> wrote in message
news:E5**********************************@microsof t.com...
Call the EnsureVisible method of the ListViewItem you want to make
visible:
ListView1.Items(N).EnsureVisible

When N is the Index of the Item you want.

"Lars Netzel" wrote:
I have a long list of Items in a ListView... if I scroll down to
something
that is not visible without scrolling and then click on it I open another
window where you can work with the details of that item..
Then I close that window I repopulate the ListView to reflect some
changes
make in the details window.. and I re-set the selected Row after the
population of the ListView so the item I was working on is selected
again..
but then the scroll is at the top..

How do I make the scroll set so that the selected Item is within the
visible
part?

(I have set the Multiselect to false so there can be only one selected)

/Lars Netzel

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Eva | last post by:
Hi, I wanted to know how i can enter values into a specific column of a listview. I have tried the following code but this seems to enter all my values into the first column!!! Can anyone...
2
by: Sakinah | last post by:
How to show item in selected listview. do I have to get listview.selecteditem index and if so how the code to get the index
1
by: youngie | last post by:
I've got a listview on a form in report style. It's populated with 40 item. I want to prevent the used clicking on some items, and if the user clicks on one of these items I want the selection to...
7
by: Visual Systems AB \(Martin Arvidsson\) | last post by:
Hi! I'v been struggeling with removing selected items from a listview. Anyone that can give me a piece of code that does this? I am a newbee to this C# and cant figure it out.... Regards...
3
by: larry mckay | last post by:
anyone have the code to select and listview item or row (subitems) after a doubleclick event from a listview. *** Sent via Developersdex http://www.developersdex.com *** Don't just participate...
2
by: amber | last post by:
Hello I have a listview that displays a list of choices When the mouse moves over each item, I would like text (the name of the item that is being hovered over) to show u in a seperate label or...
20
by: Ash Phillips | last post by:
Hi Everyone, I have this program I wrote in VB6 for family use. It's a DVD Database just for me to keep track of them cause I have so many lol. In VB6, I could add items to the ListView in...
6
Robbie
by: Robbie | last post by:
Hi again, I have a listview which gets cleared and has items added again every now and then, and it's very annoying to use because once it's cleared, the scrollbar goes back to the top. I'd like it...
7
by: Brad Pears | last post by:
I have something strange going on - pretty sure it used to work before - and now it does not... Why does the following code not clear a combo box? Me.cboLocation.Text = String.Empty OR ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.