Results 1 to 5 of 5

Thread: Textbox Question [Resolved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382

    Textbox Question [Resolved]

    I remember in VB6 when you added a new line to a multiline text box, the line would be added to the botton of all the text. Then if you wanted to have the last text entered displayed, you would do SelStart = Len(Text) and this would cause the scrollbar to be pulled all the way to the bottom of the textbox so you could see the last text added.. I can't get this to work in VB.Net.. Can anyone tell me how to do this? When I do something like this:

    txtOutput.SelectionStart = txtOutput.TextLength

    The scroll bar bounces back to the top most position after ever entry.. How do I make is so I can see the bottom portion of the test after an entry has been added?
    Last edited by Hinder; May 16th, 2004 at 06:48 AM.

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    set HideSelection to False " txtOutput.HideSelection = False "
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3
    Fanatic Member pax's Avatar
    Join Date
    Mar 2001
    Location
    Denmark
    Posts
    840
    Hi.

    You almost got it right. Problem is your code only set's the caret position. After that you need to execute the ScrollToCaret method.

    That should to do it.

    VB Code:
    1. txtOutput.SelectionStart = txtOutput.TextLength
    2. txtOutput.ScrollToCaret()
    I wish I could think of something witty to put in my sig...

    ...Currently using VS2013...

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    Dec 2002
    Posts
    382
    Originally posted by pax
    Hi.

    You almost got it right. Problem is your code only set's the caret position. After that you need to execute the ScrollToCaret method.

    That should to do it.

    VB Code:
    1. txtOutput.SelectionStart = txtOutput.TextLength
    2. txtOutput.ScrollToCaret()

    Thanks, that works great...

  5. #5
    Frenzied Member Ideas Man's Avatar
    Join Date
    Aug 2002
    Location
    Australia
    Posts
    1,718
    Don't forget to add resolved to your message. I spent hours the other day trying to find info like this, many of them unresolved or not quite what i wanted, shoulda waited a couple of days lol.
    I use Microsoft Visual Basic 2005. (Therefore, most code samples I provide will be based around the .NET Framework v2.0, unless otherwise specified)

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