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