EnsureVisible problems

pachjo

Well-known member
Joined
Dec 12, 2006
Messages
370
Programming Experience
10+
Hi,

I am trying to get my listview to automatically scroll to the last record in the list of data displayed to ensure the user sees the latest entry rather than having to scroll down each time.

I found references to the EnsureVisible() method but am unable to get it to make any difference to my application....namely it does not move to the last record!

This is what I am trying

VB.NET:
[SIZE=2]lsvListView.EnsureVisible(lsvListView.Items.Count - 1)

Any help please?

Thanks
[/SIZE]
 
Starting to lose the will to live :(

This is how I plugged your code in, thanks ;)

VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] last [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Short
[/COLOR][/SIZE][SIZE=2]last = Convert.ToSByte(lsvListView.Items.Count - 1)
lsvListView.Items(last).Selected = [/SIZE][SIZE=2][COLOR=#0000ff]True
[/COLOR][/SIZE][SIZE=2]lsvListView.HideSelection = [/SIZE][SIZE=2][COLOR=#0000ff]False
[/COLOR][/SIZE][SIZE=2]lsvListView.EnsureVisible(last)
MessageBox.Show(lsvListView.Items(last).Text)

This shows me each rows first item in turn and when the final display is up all I have is evey row selected and still no auto scroll:( :(
[/SIZE]
 
YAHOOOOOOOOOO praise the Lord I have it working :D

I found a link where someone said that the EnsureVisible method does not work when a ListView is still being updated as the ListView is not redrawn until update is complete.

I placed the call to the EnsureVisible method out side of the function that populates the ListView and.......it works :D

Hope this helps future peeps who get this same problem

Thanks chaps for all the time you spent trying to resolve this fo me
 
Back
Top