Home > Backend Development > C#.Net Tutorial > Sample code for how the C# Tabcontrol component switches to display the Form form

Sample code for how the C# Tabcontrol component switches to display the Form form

黄舟
Release: 2017-03-10 14:20:30
Original
3373 people have browsed it

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");
            }
            
        }
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template