Prevent height measurement during development

I am working on a user control. How can I prevent ONLY HEIGHT of control from changing during the development time interface.

+3
source share
2 answers

You can override the method SetBoundsCoreand prohibit height changes by changing the value heightbefore 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);
}
+2
source

You can override the Height attribute from the Control class, and then set the BrowsableAttribute so that it does not appear in the property windows

You can also see Attributes and Development Time Support

0

Source: https://habr.com/ru/post/1719610/


All Articles