Results 1 to 7 of 7

Thread: Textbox Scrollbar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188

    Textbox Scrollbar

    I am adding data to a multiline text box when data is arrived from a socket where the new text is on the bottom, I kno I can use

    textbox.text += newtext;
    textbox.SelectionStart = textbox.text.length;

    but the textbox has to have focus plus it makes the screen flicker when it does it, both I do have

    someone told me to use api's to lock the scrollbar but I haven't used api's that much

    does anyone kno what api i need to use to do this an how do i use it?

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    Hi Tewl good to see you on ere
    right i'm guessing that the textbox isnt scrolling down to show the latest data thats been added ( like it normally does in vb6 )
    you need to set the textbox's HideSelection property to False, eg:
    VB Code:
    1. [COLOR=BLUE]private[/COLOR] [COLOR=BLUE]void[/COLOR] Form1_Load([COLOR=BLUE]object[/COLOR] sender, System.EventArgs e)
    2. {
    3.     textBox1.HideSelection=[COLOR=BLUE]false[/COLOR]; [COLOR=GREEN]/// make the textbox scroll as it should, when it fills up
    4. [/COLOR]}
    5.  
    6. [COLOR=BLUE]private[/COLOR] [COLOR=BLUE]void[/COLOR] AddData([COLOR=BLUE]string[/COLOR] strData)
    7. {
    8.     textBox1.AppendText(strData); [COLOR=GREEN]/// puts the text at the end of the exsisting stuff.
    9. [/COLOR]}
    hope it helps you out m8y
    ~
    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

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    thx m8 thats just what i needed

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    Maybe you can answer one more question for me.

    When i minimize the app for awhile then restore it later on the textbox seems like it has scrolled down a bit to where i cant see any text thats at the top any ideas y an how i should fix this ;\

  5. #5
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    sorry for the delay m8, my twin babies have come home, so i'm not gonna be on my pc much now. if you want to show the last line ( eg , scroll to the end ) when the form comes back from minimized, try this...
    VB Code:
    1. [COLOR=BLUE]private[/COLOR] [COLOR=BLUE]void[/COLOR] Form1_Resize([COLOR=BLUE]object[/COLOR] sender, System.EventArgs e)
    2. {
    3.     [COLOR=BLUE]if[/COLOR]([COLOR=BLUE]this[/COLOR].WindowState!=FormWindowState.Minimized)
    4.     {
    5.         textBox1.ScrollToCaret();
    6.     }
    7. }
    ~
    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]

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    still doin it m8

    it also does this when i maximize the form leavin some of the text higher up an a huge chunk of white space at the bottom

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jun 2003
    Location
    Birmingham, AL
    Posts
    188
    nvm itchy told me how to use the sendmessage to do it

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