[英]Center panel scroll in control C#
I have a Panel
in which i'm adding controls to it dynamically. 我有一个Panel
,我在其中动态添加控件。 I want to scroll the Panel
to the position of one given control of the Panel
我要滚动的Panel
到一个给定的控制位置Panel
I'm using the ScrollControlIntoView
method of the ScrollableControl
object as follows: 我正在使用ScrollableControl
对象的ScrollControlIntoView
方法,如下所示:
public void centerPanel(Control p){
panel.ScrollControlIntoView(p);
}
But the panel seems to move to random positions. 但小组似乎转向随机位置。
The AutoScroll
property is set to True
in the Panel
. Panel
的AutoScroll
属性设置为True
。
Any thoughts ? 有什么想法吗 ?
I have detected my mistake. 我发现了自己的错误。 I was scrolling the Panel
before adding the Control
to the Panel
. 在将Control
添加到Panel
之前,我正在滚动Panel
。
So, here is the correct way to scroll a Panel
to a given control. 因此,这是将Panel
滚动到给定控件的正确方法。
panel.Controls.Add(control);
panel.ScrollControlIntoView(control);
Thanks. 谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.