C# – way to have properties for a Winforms control that behave differently at design time (in VS designer)

cnetwinforms

I am looking for a way for some controls to have Anchor = Top, Bottom, Left, Right at design time so they would change when I scale the parent form. But doesn't do this at runtime when the parent form is scaled.

Is there something like this?

Best Answer

You can use the DesignMode property to detect whether the control is currently in design mode or not. That way you should be able to set an appropriate value in the Anchor property (and other properties as well) to behave as you wish in design- and non-design modes.