By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,125 Members | 1,588 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,125 IT Pros & Developers. It's quick & easy.

ListView Scrolling not following SelectedItem?

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.