Results 1 to 7 of 7

Thread: textbox help needed....

  1. #1

    Thread Starter
    Hyperactive Member zer0_flaw's Avatar
    Join Date
    Apr 2001
    Posts
    448

    Exclamation textbox help needed....

    Well... this sounds simple but I can't figure it out. Anyway, here goes the problem: I have a textbox (text1) with a bunch of text in it. It's "multiline" option is set to "true" and has a scrollbar. How can I make it automatically start the scroll bar at the bottom, showing the last bit of text in the textbox (text1) first, instead of showing the top part of the text first automatically? Thanks for taking the time to read this... Any help is appreciated,

    -zer0 flaw

  2. #2
    Member
    Join Date
    Nov 2000
    Location
    Brisbane, Australia
    Posts
    44
    When you want to scroll to the end use the line :

    TextBoxName.SelStart = Len(TextBoxName.Text)

    Depending on when you need it, either put it in a button or in the Form Load event or whatever.
    Boring signature included.

    VB6 SP3.

  3. #3
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    That just puts the cursor at the end of the box. It does not put the scroll bar all the way at the end. I am looking for an api that does it or kinda like raise event to simulate the click to the bottom. I am surprise that there is not an Min Max for the scroll bars.
    TextBoxName.SelStart = Len(TextBoxName.Text)

  4. #4
    Member
    Join Date
    Nov 2000
    Location
    Brisbane, Australia
    Posts
    44
    Hey jjoritz

    Did you do a test at all?

    I went in and set up a demo project with a text box and a button.

    I put that line in the button's on click event and what it did was scroll the scroll bar to the very bottom. I modified the button by adding the line

    TextBoxName.SetFocus

    and now it scrolls the text box and scroll bar to the bottom and puts the cursor at the end.
    Boring signature included.

    VB6 SP3.

  5. #5
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    Yeah that does work. I put it in the Form_Load and it does not work. Like for example lets say that you check the len of the text on start of the app so i did it on the load. Well the cursor goes to the end but the scroll bar stays at the top.

  6. #6
    Frenzied Member jjortiz's Avatar
    Join Date
    Mar 2001
    Location
    NYC
    Posts
    1,768
    well anywayz try this link. It has pretty cool stuff working with the api to get control of the textbox. Let's not argue about this. Problem resolved.

    vbworld - textbox - extending the api

  7. #7
    Member
    Join Date
    Nov 2000
    Location
    Brisbane, Australia
    Posts
    44
    Fair enough

    All that's a bit complex for someone as new to VB as me.

    The simple solution I found was to stick:

    Text1.SelStart = Len(Text1.Text)
    Text1.SetFocus

    in the TextBoxName_GotFocus() event. But then I suppose that worked 'cause TextBoxName had the index of 0.
    Boring signature included.

    VB6 SP3.

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