CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  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

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