Solved

how to resize a form put inside a tabpage and keep it in sinc with main form???

Posted on 2006-11-03
5
883 Views
Last Modified: 2007-12-19
Hello

I have this tabcontrol that I put in my main form. It has three tabpages.
On the first tab I want to display a user form and I want to resize it so it matches that size on the tabcontrol. I also need to make sure the form follows the resize of the main form and the tabcontrol...

This is the code I use in the mainform's page load event to set up my user form:
        private void frmMain_Load(object sender, EventArgs e)
        {
            Form1 frm= new Form1(); // the user form to display in tab #0
            frm.TopLevel = false;
            frm.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            frm.WindowState = FormWindowState.Normal;
            tabControl1.TabPages[0].Controls.Add(frm);
            frm.Show();
        }


Which event(s) do I need to redefine? and how to figure out the size on the form inside the tab relative to the main form and the tabcontrol?

I want everithing to be resized together, the mainform, the tabcontrol and the tabs...

thanks  in advance
0
Comment
Question by:aquila98
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17871045
Try setting Dock to Fill:

    frm.Dock = DockStyle.Fill;
0
 
LVL 6

Accepted Solution

by:
so3 earned 75 total points
ID: 17872627
First of all you will get an error in your code when you use frm.show, because you can't use a form inside another control. use instead a usercontrol

Try this:

 private void frmMain_Load(object sender, EventArgs e)
        {
            UserControl frm = new UserControl(); // the user form to display in tab #0
            tabControl1.TabPages[0].Controls.Add(frm);
            frm.BackColor = Color.Red; // use this to see that the control is fully resized, delete this line after seeing
            frm.Dock = DockStyle.Fill;
        }

I saw that you use Form1 if this is a class made by you to show something then  change the class type from Form to UserControl and then use it in the frmMain_Load event.



0
 
LVL 2

Author Comment

by:aquila98
ID: 17872898
I gave points to so3 because solution was also about inheritance of userform instead of form...

thanks a lot.

0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 17873352
But for the record so3, you CAN show a form inside a container as long as the TopLevel() property is False:

    frm.TopLevel = false;

Try it for yourself please...

(aquila98 already this set in fact)
0
 
LVL 6

Expert Comment

by:so3
ID: 17873811
Idle_Mind,
yes you're right:)

thanks
0

Featured Post

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

627 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