Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Auto Scrolling The ListBox

Dear Sir

I am using VB6

Can anyone give me an idea how to scroll the list box automatically. So that I can go on adding the data and the same can be scrolled and the current line at the bottom can be seen automatically.

Thanks in advance


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Auto Scrolling To End Of Listbox..
I have a listbox that updates every x amount of time, but whenever it updates it goes back to the top.. how can i make it scroll to the bottom and maybe even stay at the bottom?

Auto Scrolling
Hey merrioncomputing,

Here is the code for this. What i am trying to do is get the notepad handle and type something in it and then fire sendmessage. Do not work for me. Can you send me your code.



I need to scroll windows explorer from my app. Its like if someone clicks on my form windows explorer should scroll.

Auto Scrolling

I am developing a application in which i have a situation where i have to somehow scroll the scrollbars of a outsourced application. Now that application does not scrolls with up down arrow keys. So i cannot just pass these keys using sendkeys. Thats a separate app. ITs like scrolling ms word from my app.

Can anybody help ?

Auto Scrolling
Discoverd it already
Its List1.Selected(List1.ListCount - 1) = true
For those who want to know

Text Box Auto Scrolling
I am currently making a chat system (client/server), and I want the chat window to automatically scroll down when text goes beyond it. I have it set to scroll; however, when text is recieved the scrollbars jump back up to the top. Anyone have any suggestions?

Auto Scrolling Web Control
Anyone know if it's possible to make MS WebBrowser control
to automatically scroll down to the bottom of the page?

Auto Scrolling Through Comboboxes
I want it so when i hit the print button, it goes to the next selection in the combo box, and prints, then moves to the next till its at the end of the combo box.....

or just make it so when print is hit it automatically goes to the next selection at the least....

Auto-Scrolling A Textbox
Question :
How can I auto-scroll a textbox ?
I use one in a little chat program, and I do something like
(on DataArrival)
Dim strdat as String
Winsock1.GetData strdat
Textbox1.text = textbox1.text & strdat
(end sub)

For some reason, when I do Textbox1.text = …… it scrolls up and that’s very annoying .
Anybody knows how I could put some code and auto-scroll the text down ?

Auto-scrolling Textbox
how do i make my textbox automatically scroll to the bottom?

FlexGrid Auto Scrolling
I have a problem in flexgrid auto scrolling. I call the scroll() method in the dragmove event:

private sub flexgrid drag_move(..., state as single)
if state=1 'Leaving flexgrid
end sub

private sub flexgrid_scroll()
flexgrid.toprow = flexgrid.toprow + 1
end sub

What i want is to scroll down or up while dragging an icon from the flexgrid if the mouse cursor is about to leave the flexgrid area. The code above works, about the scroll bar seems to go at the end of the flexgrid at the first move. Is there anyway i can do smooth scrolling and not an immediate end scroll?

Auto Scrolling In A VB App Window

Im making a VB app, which displays updates from a text file in the form of a message, in a message window. Each update is a single line, that simply says what value was added to the text file. Each message is aded to the message window one by one, as it comes in. I want the window to scroll down as new lines are added, so as to show the latest message in the window all the time. Currently, the window remains on top, and new messages are added to the window below..and i have to manualy scroll down to see the latest emssage.

Any simple way of ensuring that the window scrolls alongwiht each new entry?


Scrolling Auto Textbox
I need help with making an text box auto scroll to the bottom eveery time there is a change in it WITHOUT using the seltext or anything with selecting cuase than my progrma will counter another code out

Auto Scrolling / Focus
is there an ie.document command to auto scroll the IE window to a set position and to set the focus on a textfield?

Also to avoid anymore of these questions is there a good site with the commands for ie.document ?

Auto Scrolling A Text Box
I found code after doing a search for this topic and it works just fine. But i dont understand why it works.

VB Code:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long  Private Const EM_SCROLL = &HB5 Private Const SB_PAGEDOWN = 3  Private Sub Text1_Change()SendMessage Text1.hwnd, EM_SCROLL, SB_PAGEDOWN, ByVal 0&End Sub

There is nothing in my program that would actually call Text1_Change sub routine yet it works, which of course is a good thing. Can somebody explain to me why this works without calling the subroutine? am i missing something here?


Auto-scrolling Of The Scroll Bar
Hello everyone,

I need help for writting a code in vb such that the vectical scrollbars that are placed in my project could move itself so as to display the last word of the text being displayed. When I display long text, the whole text is displayed but the scrollbar does not move to the end of the file.

Please help... Thank you

Auto-scrolling Text Box
Hey all,

I've written an app with a textbox that I hope to have scroll to the bottom as I add information to it (a terminal window that shows processing information).

All the info I can find on this issue says to add


and possibly


This does not work.  I still have to scroll the textbox manually, at which time I can see the selection carrot at the bottom of the textbox.  Is there a way to have the textbox scroll with text as it is added?  Do I possibly have to change on of this textbox's properties?

Auto-Scrolling For RichText Box?
Hello again!

I have another question...

In my program, I am constantly sending data to this Rich Textbox...and so, is it possible for it to display the latest lines as my programing is runnning ? , i.e. display the latest information?

so that when I am finished with sending the data to this Rich Text Box...I will be looking at the last line and not the first line.

Thanks in advance!


Stop FlexGrid From Auto Scrolling To End
When filling a flexgrid with data, if in the end there are more rows or cols than fit on the screen, the grid will be scrolled down to the end.

i want it to view the grid from the beggining (top-left) by default, not the end of the grid.

i tried setting the Grid.ScrollBars property to 0 (none), filling it with data and then changing the .ScrollBars property to 3 (Both), but i still got the same result. I tried the code

FlexGrid1.col = 0
FlexGrid1.row = 0

hoping it would scroll back to the top, but no luck there either.

couldnt find anything in a search so started a new thread.

Auto Flexgrid - Issue With Scrolling
I am using FlyGuy's Autosize flexgrid for one of the columns in my flexgrid. What I am finding that is unusual is that the column seems to be extended only to a certain size. If I use the horizontal scrollbar, and scroll to the right, I cannot see the whole column, only the portion that can fit on the grid. Is there a way to scroll by something other than column?

Auto-scrolling Scroll Bars
I am making a chat program and i run into the problem of the scroll bars of the text box going all the way back to the top when i get the data. I know why this is occurning, but i was wondering if there was a way to tell the textbox to scroll all the way down to the bottom so the users don't have to scroll everytime they get a message.



Mshflexgrid && Auto Scrolling The Scrollbars
i have a mshflexgrid & i fill it with data that is bigger than the form & from the screen width sometimes also & by default the user have to scroll to the last column
how can i do this by code so once the data is filled in the mshflexgrid the scrollbar (& i mean the horizonal) is automatically scrolled to the last column

thanks in advance

Auto Panning(Scrolling) In MSFlexGrid
I want to make my flex auto scroll vertically and horizontally. Whenever I insert new row in a flex cursor goes to the new line but I have to scroll down manually to the new line. The same way, I want my flex to make move to Right and Left side.

I used SendKeys "{Down}" and everything but It couldn't work,

Pleez anybody help me out

Auto-Scrolling Text Boxes
Here is another odd one in my learning of VB6.

I have a text box that gets filled with text relatively quickly and I would like the cursor to follow the text as it gets entered into the box because as of right now it just stays at the top and the user has to scroll manually. Is there anyway to easily automate the scroll of the text box so that it follows the text being appended to it?



Very Simple PictureBox Auto Scrolling..Need Your Help
Hi..I have wrote a very simple code to scroll a picutebox automatically and on continues basis (file is attached).. I need your help in two things
1. make the scrolling from right to left
2. I want to make the pictue comes again after the first scroll ends.


Auto Scrolling A Form, While Changing Focus.
Would like to know if any of the more knowledgeable peeps out there know if it is possible to do the following:

I currently have a MDI Form on which of course other forms are loaded upon. however some of our users use different resolutions so when some of these forms are loaded they are bigger than the screen. IE the MDI form has scroll bars and the users are recquired to use them to view the rest of the form. I was wondering is there anyway to have the scroll bars automatically adjust to wherever the focus is as the user hits the tab key to jump from field to field.

Thanks in advance for anyone who can assist me.

Be assured all users who remain steadfast to their old resolutions have been flogged but have to make the masses happy.

[Not Resolved] Large Tab Control Auto Scrolling
This project is in Access2000.

I have a form with a really large tab control on it. All of the other controls belong to one of the 4 pages of the tab control. The tab control is so large, it has to be scrolled up and down. (I would make it smaller if the design of this project was up to me, but its not so i cant).

When FrmTab loads, the view is not at the top of the first page, but rather scrolled down a little bit. Also, when switching between pages, when one particular page is focused, the view is always scrolled down an inch or so.

My goal is to have the scroll bar always be at the top of the tab control when it loads, or when the page is changed.

I considered using the onchange event and the msghook package from the FAQ on how to have the mousewheel attached the scrollbar rather than the record browsing interface. This is a possible solution, but I'm eager to find a better/more simple solution, since this project will be distributed to many people, and I prefer to keep it as just 1 .mdb file.

I hope against hope that there is an easy method or trick for making this behave correctly. Any advice?

Edited by - mod on 8/23/2004 9:47:14 AM

Auto Capitalization Of Types, Eg. Listbox Vs ListBox In VBAccess Code
I have two separate Access databases. When I am writing VB code in the first database and do a Dim lb as listbox the type is autocompleted in lowercase. In the second database it is autocompleted as ListBox. Both pieces of code seem to function just fine. Why the difference?

I've used the object browser to search for "listbox" to see if I have two kinds of listboxs due to the libraries I have loaded, but I find only one ListBox and it is in VBA.

I've also noticed similar behavior for "file' vs "File".


Listbox Scrolling
Is there a way to link two list boxes when scrolling?

For example, I have two list boxes, one showing a description and the other partnumbers. Is there a way to make it so when the user scrolls in the decription list box that the PartNumber list box will also scroll, so the partnumber displayed will match the description?


Scrolling Listbox
I've seen it in other applications, but I'm not sure how to do it.

I know that you can have those listboxes that scroll up and down/left and right when they are full of data that it cannot display all at once, but there is no Scroll option in the Properties menu.

How can I get one to do this??

ListBox Scrolling
I know that when more items that can be displayed in a listbox it automatically creates a vertical scroll bar. I would like to know: is there any way I can get it to create a horizontal scroll bar when something added is to long for the listbox? Thanks.

Scrolling A Listbox
I have a listbox on my form and I want to pageup and pagedown with two cmd buttons - Is there a way to emulate the pageup and pagedown keys?

Listbox Scrolling

Picture a Listbox (in report view) with just 2 headers.
Every now and again an item gets added to the Listview.

When there are quite a lot items in the Listview, the default view is at the top.


I scroll to the bottom of the ListView to see the latest events, and when an item is added, the view scrolls all the way back to the top.

Can I somehow keep the view at the bottom.

I hope you understand
Thanks !!

Listbox Scrolling
I have a listbox where I'm adding items as my applications runs over time.

However, I'm not getting any horizontal scrollbars even though the size of my text entries is longer than my listbox width. I do get vertical scrollbars when my list grows bigger than the listbox's height, but nothing for horizontal scrolling.

What do I need to do?


Scrolling ListBox
i am currently loading the three following times in a list box as strings on form load()
List1.AddItem "11:00"
List1.AddItem "14:00"
List1.AddItem "18:30"
i currently have an UpDown1 control scrolling through these values. my problem is that when i go to submit this form, even though List1(one-lined list box) displays the time i want it is not actually selected and i cant store the value it that is displayed. ie you have to click on the time to have it highlighted/selected.
i would like it so that the value display is the value the gets submitted. i recognise that a List box might the wrong answer for this problem
any help would be greatly appreciated

Scrolling ListBox
How can I get the listbox selection to change when the user scrolls down through the options? I am using VB5.

Scrolling In A Listbox
Hello everybody!
I'm new here and have one question I couldn't find the answer yet on the net. Maybe is really simple, but I couldn't find it out.
In a list box in a form in Access, I want by clicking on the button to select the first item in the list box (this is easy) and if there are lot of items in the list, I want selected item to be visible in the box i.e. the list to scroll to the beggining. I suppose scrolling is possible in visual basic but I can't find the way to do it.

The property that easily solves the problem List1.TopIndex from VB6 is not supported by VBA (I´ve sent this message first to "Newbies" group).

Additional question: Can anybody explain me why many useful features from VB are not working in VBA??

Any idea?

Thanks in advance,


ListBox Scrolling
Is there any way to have a list box autoscroll to the bottom? I want to use one in a chat program I'm building, but I don't want users to have to constantly scroll down.

MS Access Listbox Scrolling
I have a form in an Access database. The records are navigated through clicking a listbox that contains all of the primary keys of the table. Everything works perfectly with the navigation, but the text box scroll bar is behaving badly.

When the listbox is populated with data, it apparently doesn't refresh its scrollbar so the extent is not known. Having 5,287 entries just thus far in this db, I need to have the listbox able to scroll to the very end or anywhere in between immediately. When I drag the scroll bar initially, the items in the listbox do not scroll with it, and if I drag it all the way to the bottom and drop it, it "readjusts" itself realizing that it isn't big enough and pops the scrollbar back up a ways. I have to do this 24 times before the scrollbar realizes how big the list is.

When it finally sizes itself correctly, it works perfectly! Everything scrolls normally and it all works great. Does anyone have a suggestion?

Sluggish Scrolling ListBox
i created a few different .EXE applications with VB6.0 which has 1 ListBox
(Standard Style and no MultiSelect)

Scrolling the Items in the ListBox is sluggish, jumpy, slightly erratic
doesn't respond correctly when using Mouse to scroll the ListBox.

same results running in IDE or as an .EXE

ListBox seems to respond normally after Computer Reboot, but in short time becomes sluggish to scroll, or scrolls in leaps or erractically jumps around.
as long as you Scroll slowly, the ListBox scrolls smoothly

if i read in a very large 10,000+ line Text File into the ListBox, it scrolls smoothly and very fast......if i AddItem 100 or to 1000 Lines, it eventually scrolls sluggish/jumpy,erratic.

Listbox Scrolling Looks Backwards
I've noticed this for a while and I see it is fixed in VB.NET.. but is there any way to make Listboxes not look like they are scrolling up when scrolling down?

Has anyone else noticed this? When you use the mouse wheel to scroll down a few lines in a listbox, the actual listbox view area looks as if it is going up.. even tho the new values it displays are the correct lines. But its ugly.

Listbox Scrolling Problem
I have a Listbox with 100 items in it and a command button. The code
behind the command button says

If list1.selected (i) = true
list1.topindex = list1.listindex
end if

Which brings the item selected to the top of the listbox.

This works fine, until I manually scroll to the bottom of the listbox,
select an item, and click the command button.. Then the selected item doesn't automatically scroll to the top.

Any ideas how I can get this to work ?

Problem With Listbox Scrolling
Sometimes when i add an item to my listbox i´m unable to se the whole content of the item because the content is to long.

Thats why I´m using this code so i can make a horizontal scrollbar appear if it is necessary:

VB Code:
Private Declare Function SendMessageByNum Lib "user32" _Alias "SendMessageA" (ByVal hwnd As Long, ByVal _wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongConst LB_SETHORIZONTALEXTENT = &H194  Public Sub SetListBoxWidth(ByRef MyListbox As ListBox)Dim MyTextWidth As LongMyTextWidth = 0  For j = 0 To MyListbox.ListCount - 1   If TextWidth(MyListbox.List(j))  > MyTextWidth Then     MyTextWidth = TextWidth(MyListbox.List(j))  End If Next j  If ScaleMode = vbTwips Then    MyTextWidth = MyTextWidth / Screen.TwipsPerPixelX      ' if twips change to pixels    SendMessageByNum MyListbox.hwnd, LB_SETHORIZONTALEXTENT, MyTextWidth, 0End If End Sub

Now, if i add a string to my listbox that looks something like this...:

mylistbox.additem "begin mystring" & vbtab & "end mystring"

...the code that makes the scrollbar appear doesn´t make the scrollbar long enough, so i can´t scroll enough to see the whole content of the item.

But if i add a string that looks like this...:

mylistbox.additem "begin mystring" & " " & "end mystring"

...the code that makes the scrollbar appear, now makes it long enough so i actually can see the whole content of the item. I have figured out that it must have something to do with vbTab, but i can´t understand what.

This is the code i use to set the tab-value:

VB Code:
Global Const LB_SETTABSTOPS As Long = &H192&    Declare Function SendMessage& Lib "user32" Alias "SendMessageA" (ByVal hWnd&, ByVal _  wMsg&, ByVal wParam&, lParam As Any)    Public Sub Tabstopp() ReDim tabstops(0) As Long tabstops(0) = 130     Call SendMessage(Lvisamaltid.hwnd, LB_SETTABSTOPS, 1&, tabstops(0))End Sub

Do u guys know what the problem is?

Problem With Scrolling Down Listbox
VB Code:
list1.listindex = list1.listindex + 1

When I use this it gives me an error.
"Invalid Property Value"

How do I fix this? Its just simply suppose to scroll down the list.

Scrolling Through A ListBox With Up/down Arrows
Is it possible to code a ListBox so that the user can scroll through the items using the up and down arrows? I did a search on previous postings and didn't see this particular question asked by anybody.

Listbox Enabled And Scrolling
I have a multiselection listbox with a number of checkbox styled items. I would like the use to be able to stroll through the list but not change the selection. - (Type of Access Control) -

Setting the Enabled property to false prevents the user scrolling as well as the input.

Is there a simple way to prevent selection changes but allow scrolling.

Ant help would be appreciated.

Scrolling A Disabled Listbox???

Is there any way to enable scrolling in a listbox, which allows no entries (enabled=false)???

Thanks for your help

Automatic Listbox Scrolling Down?
Hi there.

I'm using a listbox to keep a log of messages entered, and computer responses (not dissimilar to the Messenger chat log window), and I was wondering if anyone could help me have the listbox scroll to the bottom automatically, after each entry. Also... does anyone know if it's possible to alter text style (such as colour, for example) within a single listbox entry?
For example:

You said: Hello
      ^     ^
    red    blue

Or even if it could be set up to work as two separate entries, on different lines - I just don't know how to alter listbox entry colour. I'd be extremely grateful for any help offered.

Thanks again,

Edited by - The Milkybar Kid on 11/15/2003 1:36:31 PM

How Can I Automate Scrolling In A Listbox.
I currently use a textbox and a listbox. When type in the textbox it calls an api that finds the closest match in the listbox.
The item is selected in the bottom of the listbox. I would like to, however, see it selected in the top of the listbox. When I click on the vertical scrollbar i can move the items up to the top, that is what I want. I have no idea how to do it, because the listbox does not expose the scroll event. Any idea of an api that can help ?



This is what I use now, which shows the found item at the bottom of the listbox:

Private Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" (ByVal hWnd _
As Long, ByVal wMsg As Integer, ByVal _
wParam As Integer, lParam As Any) As Long


Private Sub txtsearch_Change()

        List1.ListIndex = SendMessage(List1.hWnd, _
        LB_FINDSTRING, -1, ByVal txtsearch.Text)

End Sub

Listbox Automatic Scrolling Down?
Hi there.

I'm using a listbox to keep a log of messages entered, and computer responses (not dissimilar to the Messenger chat log window), and I was wondering if anyone could help me have the listbox scroll to the bottom automatically, after each entry. Also... does anyone know if it's possible to alter text style (such as colour, for example) within a single listbox entry?
For example:

You said: Hello
      ^ ^
    red blue

Or even if it could be set up to work as two separate entries, on different lines - I just don't know how to alter listbox entry colour. I'd be extremely grateful for any help offered.

Thanks again,

Copyright © 2005-08, All rights reserved