Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autoscroll panel to bottom

Tags:

c#

.net

winforms

i have a panel in my winforms and in it i load some usercontrols .

i would like to autoscroll to the bottom of the panel( as my panel fills ) everytime a new usercontrol is added . How can i do so ?

like image 439
Alex Avatar asked Mar 31 '11 13:03

Alex


2 Answers

You can do that by setting the VerticalScroll of the Panel but I think it would be better to use ScrollControlIntoView instead.

private void panel1_ControlAdded(object sender, ControlEventArgs e)
{
    panel1.ScrollControlIntoView(e.Control);
}

Good luck!

like image 163
Homam Avatar answered Sep 28 '22 00:09

Homam


You could use ScrollControlIntoView and pass the control you last added.

An alternate solution would be:

panel.VerticalScroll.Value = panel.VerticalScroll.Maximum
like image 26
Daniel Hilgarth Avatar answered Sep 28 '22 02:09

Daniel Hilgarth