Link to home
Start Free TrialLog in
Avatar of Hepen
Hepen

asked on

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

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?
ASKER CERTIFIED SOLUTION
Avatar of arif_eqbal
arif_eqbal

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Why not use this where you have 'scroll the scrollbar all the way down:-

txtMessageHistory.SelectionStart = txtMessageHistory.Text.Length - 1