Is it possible to override a winform panel's padding in c#? -
i have simple problem have yet find simple soultion.
i'm creating custom panel has border , rounded corners. i'd able override padding, whatever user puts, i'll add value won't overlap border.i'd able both in runtime , in design time. exemple if dock control such picturebox inside panel, won't draw on borders.
i've tried override padding property, following error:
cannot override inherited member 'system.windows.forms.control.padding.set' because not marked virtual, abstract, or override
have (simple) workaround this?
well, padding property not virtual trying override can't work. you'll have replace property. requires using new keyword, troublesome way fix inheritance problems. works winforms controls since designer ever uses actual instance of control, winforms doesn't use setter , client code uses base class call setter.
so work fine:
class mycontrol : control { public new padding padding { { return base.padding; } set { // override value //... base.padding = value; } } }
Comments
Post a Comment