I tried this and it worked.
I set up 2 projects in the same namespace (don't think the namespace matters though). The first project is a class library that contains a form (Form1). The second is a Windows Application with a form that contains a Tab control (FormTab). Here are excerpts of code from the projects:
Form1:
namespace InsideForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.SetTopLevel(false);
}
public void ResetSize(System.Drawing.Size NewSize)
{
this.Width = NewSize.Width;
this.Height = NewSize.Height;
}
}
}
You see the "ResetSize" public method. It will be called by "FormTab" when it is resized.
FormTab:
namespace InsideForm
{
partial class FormTab
{
private InsideForm.Form1 MyForm;
...
private void InitializeComponent()
{
...
this.MyForm = new Form1();
this.MyForm.Location = new System.Drawing.Point(5, 5);
this.MyForm.Size = new System.Drawing.Size(391, 296);
this.MyForm.Name = "MyForm";
this.MyForm.Visible = true;
this.MyForm.Enabled = true;
...
this.tabPage1.Controls.Add(this.MyForm);
...
this.Resize += new System.EventHandler(FormTab_Resize);
this.tabControl1.ResumeLayout(false);
this.ResumeLayout(false);
}
void FormTab_Resize(object sender, System.EventArgs e)
{
tabControl1.Width = this.Width - 22;
tabControl1.Height = this.Height - 48;
MyForm.ResetSize(new System.Drawing.Size(tabControl1.Width - 10, tabControl1.Height - 10));
}
...
}
}
I'm not sure why this is not working for you.
What you don't know can hurt you!
|