Resolution independent Resizing of controls in a .net winform

Posted on 2006-11-23
Medium Priority
Last Modified: 2012-05-05
Hi Experts
        In my winform application i am using infragistics control for UI design.I want to implement resize functionality in my winforms. ie. resolution independent resizing of all the controls inside the form. i dont want to use any third party for this. Could any one please give me some code sample for this.

 Docking and Anchoring is not a solution for this
Question by:sabeesh
LVL 15

Expert Comment

ID: 18006371
Bind a delegate to the resize event of your form and resize and relayout your controls when this event is fired.
The actual code to do this will depend on what controls you have on your form and how you want them laid out.

Author Comment

ID: 18017155
Got the soluton!

Hashtable hash = new Hashtable();

            //## save default location of buttons into a
            //## hash table
            public void InitDefLoc()
                  foreach(Control cl in Controls)
                        if ((cl is Button) ^ (cl is TextBox))
            DefLocation dl = new DefLocation();

public Form1()

                  // Required for Windows Form Designer support
                  // TODO: Add any constructor code after InitializeComponent call

private void Form1_Resize(object sender, System.EventArgs e)
                  foreach (Control ctl in Controls)
                        if ((ctl is Button)^(ctl is TextBox))
                              int widthRatio = ClientRectangle.Width * 100 / startW;
                              int heightRatio = ClientRectangle.Height * 100 / startH;                        
                              DefLocation dl2 = (DefLocation)hash[ctl];
                              Point pnt = new Point((dl2.getDefCX() * widthRatio / 100),(dl2.getDefCY() * heightRatio / 100));
                              ctl.Width = dl2.getDefW() * widthRatio / 100;
                              ctl.Height = dl2.getDefH() * heightRatio / 100;
                              ctl.Location = pnt;

public class DefLocation
            int defW,defH,defCX,defCY;
            public void setDefW(int dw){
                  defW = dw;
            public void setDefH(int dh){
                  defH = dh;
            public void setDefCX(int dcx){
                  defCX = dcx;
            public void setDefCY(int dcy){
                  defCY = dcy;

            public int getDefW(){return defW;}
            public int getDefH(){return defH;}
            public int getDefCX(){return defCX;}
            public int getDefCY(){return defCY;}

Accepted Solution

Computer101 earned 0 total points
ID: 18191951
PAQed with points refunded (500)

EE Admin

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
How to fix display issue, screen flickering issue when I plug in power cord to the machine. Before I start explaining the solution lets check out once the issue how it looks like after I connect the power cord. most of you also have faced this…
If you are looking for an automated solution for backup single or multiple Office 365 user mailboxes to Outlook data file, then you can use Kernel Office 365 Backup & Restore tool. Go through the video to check out the steps to backup single or mult…

621 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