473,746 Members | 2,709 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9046
Call the EnsureVisible method of the ListViewItem you want to make visible:
ListView1.Items (N).EnsureVisib le

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.s e> wrote in message
news:eE******** ******@TK2MSFTN GP14.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).Ensure Visible()

/lars
"Lars Netzel" <ui****@adf.s e> wrote in message
news:eE******** ******@TK2MSFTN GP14.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***@discussi ons.microsoft.c om> wrote in message
news:E5******** *************** ***********@mic rosoft.com...
Call the EnsureVisible method of the ListViewItem you want to make
visible:
ListView1.Items (N).EnsureVisib le

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
6126
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 please help me out on this?? hers my code so far.....
2
1479
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
3070
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 revert back to the old selection, hideselection property if false, listview is single select. In the OnSelectedChange() handler I test to see if the newly selected item is a selectable one, if it's not, I try to change the selection like so.
7
34793
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 Martin Arvidsson
3
15719
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 in USENET...get rewarded for it!
2
2421
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 textbox How do I set this Thanks Ambe
20
6669
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 'frmMain' from 'frmAdd' with the following code: Private Function AddEntry(Title As String, Rating As String, Genre As String, OnLoan As Boolean, ToWho As String)
6
11149
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 to go back to where it was before, as if it's not obvious anything ever happened. I know there's a similar topic around, but that's in VB.NET which I'm not at all familiar with. So far I have been able to make it remember what the last...
7
3582
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 Me.cboLocation.Text = ""
0
8800
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9508
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9350
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9218
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8229
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6772
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6060
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2765
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.