【发布时间】:2014-10-08 17:16:29
【问题描述】:
我有一个属性为AutoScroll = true 的面板。
通过在不滚动的情况下向面板动态添加其他控件 - 一切正常!
void addControl(){
int top = 13 + ( this.Controls.Count * cmdSet.Height );
ucCommandSet cmdSet = new ucCommandSet() { Top = top };
this.Controls.Add( cmdSet );
}
但是,如果滚动条插入到与 TOP [0] 不同的位置,则控件会被添加到更下方。
我需要在计算中包含哪些属性?
当面问候
@LarsTech 的解决方案:
void addControl(){
int top = 13 + ( this.Controls.Count * cmdSet.Height ) + this.AutoScrollPosition.Y;
ucCommandSet cmdSet = new ucCommandSet() { Top = top };
this.Controls.Add( cmdSet );
}
【问题讨论】:
-
您能解释一下
ucCommandSet是什么吗?另外,TOP[0] 是什么意思? -
我的意思是,滚动条在顶部(Scrollvalue = 0)
-
对不起,ucCommand 是一个用户控件 ;)
标签: c# .net scroll controls add