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.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With