Results 1 to 6 of 6

Thread: How to bring the RichTextBox vertical scrollbar to lowest position ?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    How to bring the RichTextBox vertical scrollbar to lowest position ?

    Hi all . i am adding data to richtextbox and want the scrollbar to move to lowest position each time data get entred. Could you any show me how that can be done.Thabnks

    2 Code:
    1. form1.RichTextBox1.Text = ChatText$
    Last edited by tony007; Jul 17th, 2008 at 02:20 PM.

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: How to bring the RichTextBox vertical scroller bar to lowest position ?

    If you use SelText and SelLength together to add the new text to the bottom, the view scrolls to the position the text was added to.

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to bring the RichTextBox vertical scrollbar to lowest position ?

    thanks for you reply. how to lower the scrollbar to the botom each time new data get added so the user sees the fresh data without manully scrolling down. Could you show me how to use selText and sellength ?
    Last edited by tony007; Jul 17th, 2008 at 02:33 PM.

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: How to bring the RichTextBox vertical scrollbar to lowest position ?

    Code:
    Sub AddNewLine(ByRef ChatLine As String)
        RichTextBox1.SelStart = Len(RichTextBox1.Text)
        RichTextBox1.SelText = vbNewLine & ChatLine
        RichTextBox1.SelStart = Len(RichTextBox1.Text)
    End Sub
    Now you can call AddNewLine to add the new line of chat log.

    The problem that remains is that the chat log can't be scrolled conviniently as it always goes down even if user is scrolling to see the old log.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Apr 2005
    Posts
    1,907

    Re: How to bring the RichTextBox vertical scrollbar to lowest position ?

    Mery many thanks it work well. But only problem is that for some reason when i enter the data there is empty space between each line !! Is there away to avoid those empty lines ?Thanks

  6. #6
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: How to bring the RichTextBox vertical scrollbar to lowest position ?

    On that case I guess you're adding a line change yourself, so simply taking away the vbNewLine from the above code should work just fine

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