CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Autoscolling Textbox

    I need to send output in my program to a textbox on one of my forms. I use that textbox kinda like an event log. New data sent to it is appended to the text already there. Everytime data is sent, the textbox scrolls itself back up to the top- how do I make it autoscroll to the bottom of the text? Thanks!!!

    Jeff


  2. #2
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Autoscolling Textbox

    After adding the text, set the SelStart to the end of the textbox thus:


    Text1.SelStart = len(Text1.Text)




    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

  3. #3
    Join Date
    Apr 2000
    Location
    South Carolina,USA
    Posts
    2,210

    Re: Autoscolling Textbox

    Here is a litle sample that miught be of interest.
    Start a new project. Add a textBox and a command button. Paste this code into the general declarations section of the form. Run the program.
    Click the command button after everything settles down.
    The key to this is the Selstart, SetFocus and sendkeys.

    option Explicit
    Dim X

    private Sub Command1_Click()
    Text1.SetFocus
    X = X + 1
    SendKeys "This is line " & X & vbCr
    End Sub

    private Sub Form_Load()
    me.Show
    Text1.SetFocus
    for X = 1 to 10
    Text1.SelStart = len(Text1.Text)
    SendKeys "This is Line " & X & vbCr
    next X


    End Sub




    John G

  4. #4
    Join Date
    Jun 2001
    Location
    Memphis, TN
    Posts
    146

    Re: Autoscolling Textbox

    Thanks for the quick response ya'll! Works like a charm!

    Jeff the appreciative programmer


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