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.
Printable View
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.
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
heh
was exactly what i was looking for. i thought about selectedindex but didn't think it was going to scroll to select the item.VB Code:
Me.lstEuler.SelectedIndex = Me.lstEuler.Items.Count - 1
thanks!
p.s.: is there any reason for using Me.? it worked without is it necessary if there are multiple forms?
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 .