Controlling the max size of a button

We're creating base classes inherited from the standard WinForm controls.  As part of a proof-of-concept, I need to demonstrate "why" this inheritance is a good thing.  

One of the things I'd like to demonstrate is the enforcement of a maximum size (height and width) of a button, particularly at design time.  I figured all I would need to do is override the Width and Height property, eg:

public override Width
{
   get{return base.Width;}
   set{if(value > 100) value=100; base.Width = value;}
}

however, the Width property is not overridable.

Any thoughts

Rob


Answer this question

Controlling the max size of a button

  • ksalter

    Most excellent. Thank you!
  • mcclgn

    Override SetBoundsCore instead of the property. Add any restrictions in your override.

    -mark

  • Controlling the max size of a button