How to keep a vertical scrollbar on a multiline textbox always scrolled down?

Posted on 2006-05-09
Last Modified: 2008-02-01
How to keep a vertical scrollbar on a multiline textbox always scrolled down?

My multiline textbox is being used as a chat text box.  When the text inside gets too big I have to trim the top but keep the chat contents on the bottom.

            If txtMessageHistory.Text.Length > 2048 Then
                'take the last 2048 characters and set that
                txtMessageHistory.Text = txtMessageHistory.Text.Substring(txtMessageHistory.Text.Length - 2048, 2048)
                'scroll the scrollbar all the way down
                ?? HELP
            End If

The scrollbar gets set all the way up instead of staying scrolled down.

Any suggestions?
Question by:Hepen
    LVL 19

    Accepted Solution

    To scroll to the bottom


    This should do....
    However what I can understand is, that you have a chat page where user types in one textbox and on send button it goes to the Display Text box and for that you are using something like  
           txtMessageHistory.Text &= TextBox1.Text
    instead of that try
    The scroll bar would automatically be at the end

    LVL 6

    Expert Comment

    Why not use this where you have 'scroll the scrollbar all the way down:-

    txtMessageHistory.SelectionStart = txtMessageHistory.Text.Length - 1

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
    Introduction When many people think of the WebBrowser ( control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now