protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
height = 50;//这里为了简单直接定义高度为50
//你可以检查属性等然后计算得出合适的高度
base.SetBoundsCore (x, y, width, height, specified);
}
最简单地,可以这样:
const int _HEIGHT = 25;
public new Size Size
{
get{return base.Size;}
set{base.Size = new Size(value.Width,_HEIGHT);}
}
public new int Height
{
get{return _HEIGHT;}
}
这样无论设计器还是代码都没法改变其高度了