Central scroll pane in a C # control

I have Panelone in which I add controls to it dynamically. I want to scroll Panelto the position of one given controlPanel

I use the ScrollControlIntoViewobject method ScrollableControlas follows:

public void centerPanel(Control p){
        panel.ScrollControlIntoView(p);
    }

But the panel seems to be moving in random positions.

The property AutoScrollmatters Truein Panel.

Any thoughts?

+5
source share
1 answer

I found my mistake. I scrolled Panelbefore adding Controlin Panel.

So, here is the correct way to scroll a Panelto a given control.

panel.Controls.Add(control);
panel.ScrollControlIntoView(control);

Thank.

+1
source

All Articles