URGENT: Make Windows Forms Zoom in/out

Posted on 2005-05-16
Medium Priority
Last Modified: 2012-06-27
Is there an easy way to make a Windows Forms form zoomable?  For instance, I have a MDI child window that a user is currently viewing and they would like to be able to make it larger (all controls/text) so that other people standing around the monitor (or a large screen during a meeting) can easily view the text/etc.

Is there a simple way to do this in .NET?


View | Zoom | 125% or 150% etc...
Question by:slapiwite
  • 4
  • 3

Author Comment

ID: 14015204
It would actually be nice if I could make it apply to every window in the parent as well - but most important is at least being able to do it to the currently selected form.

Author Comment

ID: 14015225
Also, I thought of changing the base forms font size - as it will then apply to child controls - but that isn't working well at all.  It doesn't apply to embedded controls and also doesn't update the size of the control so then the text gets cut-off.

Expert Comment

ID: 14015328
Hi slapiwite,

You could do a fairly simple zoom like this...

            double z = 2;
            this.Size = new Size((int)(this.Size.Width * z), (int)(this.Size.Height * z));
            foreach(Control c in Controls)
                c.Location = new Point((int)(c.Location.X * z), (int)(c.Location.Y * z));
                c.Size = new Size((int)(c.Size.Width * z),(int)(c.Size.Height * z));

Regards -A.R
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Accepted Solution

AaronReams earned 1500 total points
ID: 14015346
You could also add the following line if you want to zoom the font for all controls as well...  You just need to tweak the "15F" which specifies the size of the font.

c.Font = new System.Drawing.Font("Microsoft Sans Serif", 15F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

Hope this helps.   Cheers -A.R.

Author Comment

ID: 14040901
Thanks for the tips - that got me headed in the right direction.

After trying that approach, I realized that it wouldn't work very well because some of the nested & custom controls would never look right (ended up with some very weird results).  However, I stumbled across an even easier way:

form1.Scale(1.5F);  //e.g. 150% zoom

then, all you need to do is update the form's font & all is well.

The only issue with this is that it doesn't seem to work if I use a font on a control (that control will not scale properly).  However, if you keep the default font - it works nicely.  I've logged a bug to see if hte font default issue is a bug or not, but for now this is good enough.

Thanks for responding!

Author Comment

ID: 14040907
Giving you the points for helping :)

Expert Comment

ID: 14040928
Oh, kewl, thanks for the "counter" tip.  I didn't realize there was a Scale function, but that makes sense.  I'll have to give it a shot.

Happy coding.


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question