c# - How to subsequently add scaling behaviour in a WinForms application? -
i working on winforms application using visual studio 2008 (c#). user interface of concerning form consists of several splitcontainers. when tested application after setting windows font size 125%, form didn't more should. there problem scaling. therefore i've searched solution , found 1 here. 2 following lines did job me:
this.autoscaledimensions = new system.drawing.sizef(6f, 13f); this.autoscalemode = system.windows.forms.autoscalemode.font; as explained in other question (in 1 of answers, respectively), have included every container in designer file. works , scaling performs correctly. on other hand, have manually edit designer file , that's 1 shouldn't do. added lines lost every time use layout designer. edit: clarify: these 2 properties not shown in designer gui.
now finally, question is: can do? how or can add code correct scaling without dirty manipulation of designer file?
i have tried put these 2 lines every container in constructor after initializecomponent() method call, @ position, don't have desired effect.
so, maybe have idea how has done.
thanks in advance,
alex
i've found way solve problem. isn't intended originally, has same effect.
the concerning 2 properties don't show in designer gui, why not make them appear? therefore created custom control , added attributes both scaling properties, appear in designer.
public class scalablesplitcontainer : splitcontainer { [browsable(true)] [editorbrowsable(editorbrowsablestate.always)] [designerserializationvisibility(designerserializationvisibility.visible)] [bindable(true)] public new autoscalemode autoscalemode { { return base.autoscalemode; } set { base.autoscalemode = value; } } [browsable(true)] [editorbrowsable(editorbrowsablestate.always)] [designerserializationvisibility(designerserializationvisibility.visible)] [bindable(true)] public new sizef autoscaledimensions { { return base.autoscaledimensions; } set { base.autoscaledimensions = value; } } } using specialized splitcontainer, scaling behaviour can set in gui , code lines included in generated designer file.
Comments
Post a Comment