tags:

views:

3061

answers:

5

Is there an easy way to set the zoom level for a windows form in C#? In VBA there was a zoom property of the form.

A: 

Can you specify what kind of form? Are we talking about web forms and text encoding sizes?

Jon Limjap
+1  A: 

There is no way (that I know of) to do what you ask with typical WinForms.

If you're doing custom painting/drawing, you can zoom that by using a zoom transform, but so far as I know there is no "Zoom" property for the form in the entire world of .NET and native Windows/C++ APIs combined.

You could probably rig something yourself such that you scale controls by a constant factor. And you can probably find 3rd-party controls/surfaces which support this. And who knows what is possible with WPF. But in a typical WinForms world, no.

James D
Here is the method: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.scale.aspx. Of course you shall keep track of original controls size since after having scaled controls their scaled value is approximated to an integer value (so, successive zoom in-out operation may lead to incorrect original sizes).
Luca
A: 

I agree with @CodingTheWheel. Unless you are doing this in WPF, traditional windowsforms have no automated way of "zooming in" without having to iterate through all controls and manually jacking up their sizes.

Jon Limjap
+2  A: 

I had the same problem and I solved this way in c#. Code goes on Form load

float scaleX = ((float)Screen.PrimaryScreen.WorkingArea.Width / 1024); float scaleY = ((float)Screen.PrimaryScreen.WorkingArea.Height / 768); SizeF aSf = new SizeF(scaleX, scaleY); this.Scale(aSf);

This "more or less" scales form and all children. Loops forever in 800x600 (?) You have to set the following Form properties

AutoscaleMode = Font AutoSize = False

Hope this helps, Fabrizio

A: 

hi what can i do to zoom out my win forms?

tara