Hi evirione For any one interest in this Here I publish my solution Object in Form1 splitContainer1 tabControl1 (in the right panel of the splitContainer1) The tabControl does not have any page on design. The left panel I intent to put a treeView, but for this code, there is a button button1 (in the left panel of the splitContainer1) this is the code for the button click event
private void button1\_Click(object sender, EventArgs e)
{
TabPage newTabPage = new TabPage("Form " + tabControl1.TabPages.Count);
newTabPage.Size = new Size(tabControl1.Width, tabControl1.Height);
Form2 newForm = new Form2();
newForm.TopLevel = false;
newForm.Parent = this;
newForm.Visible = true;
newForm.Location = newTabPage.Location;
newForm.Location = new Point(3, 3);
newForm.Size = new Size(newTabPage.Width - 3, newTabPage.Height - 3);
newForm.FormBorderStyle = FormBorderStyle.None;
newTabPage.Controls.Add(newForm);
tabControl1.TabPages.Add(newTabPage);
}
Becaus Microsoft does not provide the Tab control we all use in the IDE, that allow to close a tabpage with an X in the upper right corner, I have no alternative and just use a normal tabControl Now, in order to destroy the tabpage when closing the form created on each page. In Form2 I add a button, and the followin code.( this close the form and destroy the tab page.
private void button1\_Click(object sender, EventArgs e)
{
TabPage tab = this.Parent as TabPage;
TabControl tabControl = tab.Parent as TabControl;
tabControl.TabPages.Remove(tab);
this.Dispose();
}
Hope this help Cristian Conrads
modified on Monday, March 2, 2009 7:05 PM