CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Guest

    Making A Textbox scroll to the bottom on every update

    Hi my name is Will and I am having a problem with a rich text box in my program. You see, I am working on an encryption and then I want to decrypt the text and put it into a text box. But the text can be larger than the text box so I have scroll bars. But every time I want the user to be able to update it, the text box starts from the top and they have to keep scrolling down and that can get very boring after a while. So what I need is to be able to make the text box scroll all the way to the bottom when it has a changed event. A good analagy would be AOL's IM's. They always scroll to the bottom when someone sends a message. Thank you for your help. It will be greatly appreciated!

    -Will


  2. #2
    Join Date
    Jan 2000
    Location
    CA
    Posts
    52

    Re: Making A Textbox scroll to the bottom on every update

    Try this



    private Sub RichTextBox1_Change()
    RichTextBox1.SelStart = len(RichTextBox1.Text)
    RichTextBox1.SelLength = 1

    End Sub





    This selects the last character of the textbox which forces a scroll to the bottom of the document.

    Good Luck


  3. #3
    Guest

    Re: Making A Textbox scroll to the bottom on every update

    I'm not really sure if this is what you want to acheive but if all you want to do is set the curson position to be that of the last character in the rich text box then just use the send keys function
    ie
    richtext1_change()

    SendKeys "^{END}"



    end sub
    the only problem with this is that if a user starts typing at the end of your text then the computer beeps but this can be stoppen by using the following
    CONSTANT and FUNCTION

    private Const SPI_SETBEEP = 2
    private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" (byval uAction as Long, byval uParam as Long, byref lpvParam as Any, byval fuWinIni as Long) as Long



    and then calling where ever you want

    Call SystemParametersInfo(SPI_SETBEEP, false, 0, 0)



    recalling it with false set to true turns the beep back on


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

Featured