我想要创建一个包含25 to头的控件。当我添加子控件时,我希望它们的行为像在GroupBox中使用一样。当控件的DockStyle设置为填充组框时,它的位置自动设置为3;16,其大小设置为Width-6; Height-19。我不想不使用填充或边距,因为它们似乎不在GroupBox中使用。
我如何在自己的控件中实现相同的行为?
发布于 2014-03-06 21:43:21
尝试重写面板的DisplayRectangle属性:
public class MyContainer : Panel {
public override Rectangle DisplayRectangle {
get {
int headerHeight = 25;
return new Rectangle(
this.Padding.Left,
this.Padding.Top + headerHeight,
this.ClientSize.Width -
(this.Padding.Left + this.Padding.Right),
this.ClientSize.Height -
(this.Padding.Top + this.Padding.Bottom + headerHeight));
}
}
}https://stackoverflow.com/questions/22236082
复制相似问题