CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Problems with resize

    I've created a form which contains several controls. The main control is a tabControl, which contains several other controls. When I resize the main form, the tabs resize with no problems. But the controls in the tab are not resizing properly.

    The attached screen shot, padefaultsize shows the form in it's normal state. When I resize, I expand the tab and the controls in the tab. The rest do not resize.

    The screen shot paresized shows the form after I resize it. My graph (zgPeriodic) and panel (pnlPeriodic) drift outside of the tabs. I have the graph anchored at the bottom left, and the panel at the top right.

    My code is as follows...

    Code:
    public void Form1_Resize(object sender, System.EventArgs e)
            {
                Control control = (Control) sender;
    
                // resize tabPages
                int tabh = (int)Math.Round((decimal)(control.Size.Height - 120));
                int tabw = (int)Math.Round((decimal)(control.Size.Width - 200));
    
                tabPages.Size = new Size(tabw, tabh);          
    
                // resize periodic tab
    
                int periodicheight = (int)Math.Round((decimal)tabh / 2) - 2;
                int zgperiodicheight = tabh - periodicheight - 45;
                int gridwidth = (int)Math.Round((decimal).5775 * tabw);
                int graphwidth = tabw - 12;
                int pnlwidth = tabw - gridwidth - 19;
    
                gridPeriodic.Size = new Size(gridwidth, periodicheight);
                pnlPeriodic.Size = new Size(pnlwidth, periodicheight);
                zgPeriodic.Size = new Size(graphwidth, zgperiodicheight);
            }
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2010
    Posts
    1,133

    Re: Problems with resize

    Try not to manually resize the controls (just comment it all out - you can always uncomment later). Each control has the Anchor property that tells it how to maintain the distance between each of its edges and the edges of its parent control - try playing with that. You can even test how it behaves in the designer.

  3. #3
    Join Date
    Feb 2010
    Posts
    14

    Re: Problems with resize

    Hi, the first thing that comes to mind is that the bitmap is maintaining proportions. Make sure you haven't got sizing uniform in the properties.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured