Results 1 to 5 of 5

Thread: Auto scrolling to bottom of textbox. [Resolved]

  1. #1

    Thread Starter
    Member Jared's Avatar
    Join Date
    Nov 2002
    Posts
    58

    Auto scrolling to bottom of textbox. [Resolved]

    I am taking string text data and passing it to a Sub. All the text appears in the text box okay, but I can't get the scroll bar to go to the bottom of the textbox. After each new addition of text, the scrollbar stays at the top. Here is the code that I am using:


    Private Sub WriteMessage(ByVal message As String)

    Me.TextBox1.Text += message + vbCrLf
    Me.TextBox1.SelectionStart = Len(TextBox1.Text)

    End Sub


    I have read other suggestions from the past forums, but those didn't seem to work.
    Last edited by Jared; Nov 29th, 2002 at 01:39 PM.

  2. #2
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Code:
    Me.TextBox1.ScrollToCaret()

  3. #3

    Thread Starter
    Member Jared's Avatar
    Join Date
    Nov 2002
    Posts
    58
    Thanks for replying so quickly, but I have tried adding that to the end of the above code, and it didn't work.

    Jared.

  4. #4
    Registered User
    Join Date
    Nov 2002
    Location
    Växjö, Sweden
    Posts
    314
    Ok?!? Strange, The code I tried it on was yours.

    I added a TextBox1, set the ScrollBars property to Vertical, filled the variable "message" with a text and copied you code from the thread and called it from a button click event.

  5. #5

    Thread Starter
    Member Jared's Avatar
    Join Date
    Nov 2002
    Posts
    58


    It worked!

    When I tried previously, I must have made a mistake the first time when I put the line in.

    Thanks!

    Jared.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width