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.
+2
A:
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);
}
Jeff Yates
2009-10-08 12:15:58
A:
You can override the Height attribute from the Control class and then set the BrowsableAttribute to prevent it from being displayed in the properties windows
You can also take a look at Attributes and Design-Time Support
armannvg
2009-10-08 12:17:12