Hello,
I am looking for this all over the internet.
How Do U Make A List Box Scroll Down Automatically?
Hello,
I am looking for this all over the internet.
How Do U Make A List Box Scroll Down Automatically?
You could just scroll to the bottom as items are added.
List1.Additem "foo"
List1.Listindex = List1.NewIndex
You could just scroll to the bottom as items are added.
List1.Additem "foo"
List1.Listindex = List1.NewIndex
Thanks a lot. This works!
Hi,
This can very easily be achieved if you're using VB.NET. Here's an example:
1. I have a list box named lstBox. It's got a couple of items added to it beforehand. I add a new item:
lstBox.Items.Add ( "NewItem" )
2. Now the number of items in a listbox is returned if you call the Count method of ListBox.Items. So:
lstBox.Items.Count - will give me the total item count including the newly inserted item.
3. Now third step is to select the last item - which can be achieved by using the SelectedIndex method of Listbox. SelectedIndex accepts an integer as it's parameter to indicate which item to select. Keep in mind, that this index is ZERO based. So the indices of the items in the list, start from 0 ..upto.. (n-1), where n = lstBox.Items.Count
So all I need to do is, lstBox.SelectedIndex = lstBox.Items.Count - 1 - this single line will do the trick
Hope this helps...
Regards,
If you don't want to have to select an item in the ListBox, you can change the TopIndex property -> it returns or sets the index of the first item visible at the top.
I had to use this today - because I was using the SelectedIndexChanged event to run some code that went to another screen - I needed the Listbox scroll position to bethe same when the user returns to it - without having to select an item.
Bookmarks