Listview Scroll ( ensurevisible not available)

jwh

Well-known member
Joined
Aug 18, 2006
Messages
155
Programming Experience
3-5
Hello.

I Have a listview with several items in it.

How do I get the listview to scroll down when another item is added?

In winforms, I could just call ensurevisible() on the item in question, and the listview would scroll, but (even though MSDN says to the contrary) there is no EnsureVisible method in the CF.


How can I implement this behaviour?
 
Hello,

You may use the SelectedItem property of the ListBox. The code below achieves the desired:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.ListBox1.Items.Add("one")
Me.ListBox1.Items.Add("two")
Me.ListBox1.Items.Add("Three")
Me.ListBox1.Items.Add("Four")
Me.ListBox1.Items.Add("Five")
Me.ListBox1.Items.Add("Six")
Me.ListBox1.Items.Add("Seven")
Me.ListBox1.Items.Add("Eight")
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.ListBox1.SelectedItem = "Eight"
End Sub

Regards,
Dave

Dave Traister
Software Engineer
ComponentOne LLC
 
Back
Top