Home > Article > Backend Development > Sample code for how the C# Tabcontrol component switches to display the Form form
c# How to display FORM in the tabcontrol component
As the title states, when you click an item in the menuStrip1 component or toolStrip1 component, the FORM will no longer jump out and all will be displayed in the tabcontrol. The title name of the displayed Tabpage page is also based on this component. The name of an item in the FORM form is designed first, and all the content needs to be turned into a label form; every time a new form is added, the new form will be displayed, and if the form is closed, the previous one will be displayed. Open form.
C# code private void button2_Click(object sender, EventArgs e) { bool have = false; foreach (TabPage a in tabControl1.TabPages) { if (a.Name == "KKK") //tabpage名 kkk { have = true; } } if (!have) { TabPage TabPageCity1 = new TabPage("KKK"); TabPageCity1.Name = "KKK"; this.tabControl1.TabPages.Add(TabPageCity1); FormCity frmCity = new FormCity(); //FormCity:From frmCity.TopLevel = false; frmCity.Parent = TabPageCity1; frmCity.ControlBox = false; frmCity.Dock = System.Windows.Forms.DockStyle.Fill; frmCity.Show(); this.tabControl1.SelectedTab = TabPageCity1; } else { MessageBox.Show("cz"); } }
Set FormBorderStyle to None and there will be no title bar
The above is the detailed content of Sample code for how the C# Tabcontrol component switches to display the Form form. For more information, please follow other related articles on the PHP Chinese website!