URGENT: Make Windows Forms Zoom in/out

Posted on 2005-05-16
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

    Author Comment

    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

    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.
    LVL 8

    Expert Comment

    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
    LVL 8

    Accepted Solution

    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

    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

    Giving you the points for helping :)
    LVL 8

    Expert Comment

    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.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    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…
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    760 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

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now