Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent height sizing at design time

I'm working on a custom user control. How can I prevent the HEIGHT ONLY of the control from being modified during the design-time interface.

like image 759
DRapp Avatar asked May 08 '26 19:05

DRapp


1 Answers

You can override the SetBoundsCore method and disallow changes to height by changing the height value before calling the base class implementation.

private const int FixedHeightIWantToKeep = 100;

protected override void SetBoundsCore(
    int x,
    int y,
    int width,
    int height,
    BoundsSpecified specified)
{
    // Fixes height at 100 (or whatever fixed height is set to).
    height = this.FixedHeightIWantToKeep;
    base.SetBoundsCore(x, y, width, height, specified);
}
like image 148
Jeff Yates Avatar answered May 11 '26 09:05

Jeff Yates