Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: VB .NET 2010: Auto Scroll to Bottom  (Read 25447 times)

0 Members and 1 Guest are viewing this topic.

Fleexy

    Topic Starter


    Intermediate

  • OW NEXT TIME I SHOULD TURN IT OFF BEFORE SERVICING
  • Thanked: 2
    • Yes
    • Yes
  • Experience: Experienced
  • OS: Windows XP
VB .NET 2010: Auto Scroll to Bottom
« on: January 21, 2011, 07:01:06 PM »
Could somebody please explain to me how to make a MultiLine textbox scroll to the bottom automatically?  I am using VB .NET 2010.  I just can't figure it out.

%FLEEXY
I love .NET!

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: VB .NET 2010: Auto Scroll to Bottom
« Reply #1 on: January 21, 2011, 07:31:15 PM »
Set the selection start to the end of the textbox and use the ScrollToCaret() method:

Code: [Select]
textBox1.SelectionStart=textBox1.Text.Length
textBox1.ScrollToCaret()
You could do other  things as well, such as saving the original caret position or any selections that were made, depending on when you are triggering this change and how you are using the textbox.
I was trying to dereference Null Pointers before it was cool.