I've a panel with property AutoScroll
= true
. By adding other controls dynamically to the panel without scrolling - all works fine!
void addControl(){
int top = 13 + ( this.Controls.Count * cmdSet.Height );
ucCommandSet cmdSet = new ucCommandSet() { Top = top };
this.Controls.Add( cmdSet );
}
But, if the scrollbar is inserted in a different position than TOP [0], the controls are added much further down.
What property do I need to include in the calculation?
regards raiserle
Solution by @LarsTech:
void addControl(){
int top = 13 + ( this.Controls.Count * cmdSet.Height ) + this.AutoScrollPosition.Y;
ucCommandSet cmdSet = new ucCommandSet() { Top = top };
this.Controls.Add( cmdSet );
}
I'm guessing you need to compensate for the scroll position:
{ Top = top + this.AutoScrollPosition.Y };
A FlowLayoutPanel does this for you, by the way.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.