0
我试图调整自定义面板控件的大小,使其适合父容器的宽度。当我检查控件值时,它们都是相同的,但子控件对于父控件来说太宽了。当宽度相等时子控件大于父元素
什么是造成差异?我想能够计算出正确的尺寸。我试着改变填充和边距选项,但是这没有任何效果。
[Category("Collapsible Panel")]
[DesignOnly(true)]
[DefaultValue(false)]
[Description("If True, fits the panel to match the parent width")]
public bool FitToParent
{
get { return _fitToParent; }
set {
_fitToParent = value;
if (_fitToParent)
{
if (this.Parent != null)
{
this.Location = new Point(0, this.Location.Y);
this.Size = new Size(this.Parent.Size.Width, this.Size.Height);
this.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
}
}
else
{
this.Anchor = AnchorStyles.Top | AnchorStyles.Left;
}
}
}
+1看起来就是这样的问题 –
邦上,谢谢:) – Amicable