Link to home
Start Free TrialLog in
Avatar of aquila98
aquila98

asked on

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

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
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Try setting Dock to Fill:

    frm.Dock = DockStyle.Fill;
ASKER CERTIFIED SOLUTION
Avatar of so3
so3
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aquila98
aquila98

ASKER

I gave points to so3 because solution was also about inheritance of userform instead of form...

thanks a lot.

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)
Idle_Mind,
yes you're right:)

thanks