scroll to bottom

how do i make my panel scroll automatically to the latestest content.. My panel starts with showing the data on top and then the new data comes down and down and then scroll bar shows up which keeps getting bigger but i can't see my new data without scrolling. How can i make scrollbar autoscroll to the latest data

thx

Sameep



Answer this question

scroll to bottom

  • Kamii47

    Assuming you're putting controls on the panel, just set the focus to the last control.


  • Buck Hodges

    Sorry perhaps I should have listed a separate thread - it was just that someone else seemed to have answered my question when attempting to answer the above question so I thought I would be better phrasing mine here. The top question has already been answered.

  • davehomebrew

    Loop over all controls on your panel, and see what control is most to the right and to the bottom of the panel, then for this control call ScrollControlIntoView(control).

    Mikhail.


  • DTHMTLGOD

  • Boulderdude

    If you are wanting to automatically scroll to the end of a multi-line textbox after lines have been added to it at the bottom, try this:

    textBox1.Select(textBox1.TextLength, 0);
    textBox1.ScrollToCaret();



  • DavidLong

    This is precisely what I am wanting to do, but I can't get your code to work.

    My code fragment is included below.

    What I want is for the textbox to contain the reams of info (don't know if it matters but includes newlines) stored in my arrayofoptions object - but to display only the final 3 lines or so (but in such a way that if anyone wants to scroll up they can). Any help greatfully received. Thanks

    Dim pretext As TextBox = New TextBox()

    pretext.Location = New System.Drawing.Point(5, 10)

    pretext.Size = New System.Drawing.Size(510, 50)

    pretext.ReadOnly = True

    pretext.Multiline = True

    pretext.ScrollBars() = System.Windows.Forms.ScrollBars.Vertical

    pretext.Text = arrayofoptions(whichquestionimon).PreContext

    pretext.BorderStyle = BorderStyle.None

    pretext.Select(pretext.TextLength, 0)

    pretext.ScrollToCaret()

    groupBox1.Controls.Add(pretext)



  • MagedSalah

    If the content are individual controls then you can use these 2 methods to bring the control to view.

    mycontrol.BringToFront() // selects the control
    mypanel.ScrollControlIntoView(mycontrol) // scrolls to the control

     


  • scroll to bottom