|
|
|
|
![]() ![]() |
May 17 2005, 12:38 PM
Post
#1
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 23 Joined: 16-May 05 Member No.: 5,110 |
Hi,
I'm just writing a small program with a friend that is kind of pointless at the moment My question is, is it possible to make a listbox automatically scroll to the bottom of the list when a new item is added? if so can anyone please let me know? Thank you all in advance for your help. P.S. Sorry if it's a silly question that i should know the answer to, but neither of us have touched VB in ages. This post has been edited by microscopic^earthling: May 17 2005, 06:02 PM |
|
|
|
May 17 2005, 02:03 PM
Post
#2
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
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, m^e |
|
|
|
May 18 2005, 01:56 AM
Post
#3
|
|
|
Newbie [ Level 2 ] Group: Members Posts: 23 Joined: 16-May 05 Member No.: 5,110 |
We are using VB6, but the code that you gave helped me work out the VB6 alternative and it is now working. "lstBox.ListIndex = lstBox.ListCount - 1" as you can see very little has changed |
|
|
|
May 18 2005, 09:31 AM
Post
#4
|
|
|
PsYcheDeLiC dR3aMeR Group: Admin Posts: 2,242 Joined: 29-January 05 From: Nakorn Chaisri, Thailand Member No.: 2,411 |
Glad that helped
Issue resolved. Topic closed. |
|
|
|
Nov 5 2007, 11:47 PM
Post
#5
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
Im trying to figure out how to select all items in a listbox so I can move them from 1 listbox to another on click.I figured out how to make a timer to do this but how would I stop the timer after it has moved every item 1 time or is there a easier way ? Im working in vb6
-newbietoVB6 |
|
|
|
Jun 21 2008, 07:23 AM
Post
#6
|
|
|
Newbie [ Level 1 ] Group: Members Posts: 0 Joined: 1-November 07 Member No.: 25,869 |
how to auto move between contents in a list box using a timer
VB: Howto Auto-select Last Item In Listbox I'm also writing a simple program at the moment. I want to auto scroll the selected items in a listbox using a timer so when the item is selected it displays on a textbox and I can use two control buttons to stop and start. By this way I could choose a random number from the listbox. I just need some help for the code to move between items in a listbox automatically using timer control. Thanx in advance -question by aisha |
|
|
|
![]() ![]() |
Similar Topics
| Topics | Topics | |
|---|---|---|
|
|
|
Lo-Fi Version | Time is now: 5th September 2008 - 12:07 PM |