|
-
Mar 5th, 2004, 04:40 PM
#1
Thread Starter
Addicted Member
Autoscrolling a listbox?
hi.
i have a listbox in which a looped function continually adds items. the user can stop this and scroll down, but is there a way the listbox can be automatically scrolled down to the newest item?
thanks.
-
Mar 5th, 2004, 04:48 PM
#2
Sleep mode
Add timer , set its properties like this
Enabled=True
Interval=2000
then add this code , it selects the last item was added .
VB Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles Timer1.Tick
For i As Integer = 0 To 5
Me.ListBox1.Items.Add(i.ToString)
Next
Me.ListBox1.SelectedIndex = Me.ListBox1.Items.Count - 1
End Sub
-
Mar 5th, 2004, 04:55 PM
#3
Thread Starter
Addicted Member
heh
VB Code:
Me.lstEuler.SelectedIndex = Me.lstEuler.Items.Count - 1
was exactly what i was looking for. i thought about selectedindex but didn't think it was going to scroll to select the item.
thanks!
p.s.: is there any reason for using Me.? it worked without is it necessary if there are multiple forms?
-
Mar 5th, 2004, 04:59 PM
#4
Sleep mode
Not necessary but got used to OOP . Me refers to the instance you're currently working with . You can leave it out if you don't like but also it ease some part of typing the whole control name .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|