Home > DeveloperSection > Articles > Tab Control in CSharp .NET

Tab Control in CSharp .NET


C# C# 
Ratings:
0 Comment(s)
 3764  View(s)
Rate this:

Tab Control in .Net Using C#

When we want to have more than one page on a single form then we use Tab Control. Here I have used Tab Control with two pages, tabPage1 and tabPage2. TabPage1 contains Radio Buttons while tabPage2 contains TreeView.

You can simply drag and drop Tab Control from tool box of VisualStudio.

 

Coding of controls present in tabPage1.

  private void rdoRed_Click(object sender, EventArgs e)

        {

            this.BackColor = Color.Red;

            gbColor.ForeColor = Color.Red;

            btnDefault.ForeColor = Color.Black;

        }

       

        private void rdoBlue_Click(object sender, EventArgs e)

        {           

            this.BackColor = Color.Blue;

            gbColor.ForeColor = Color.Blue;

            btnDefault.ForeColor = Color.Black;

        }

 

        private void btnDefault_Click(object sender, EventArgs e)

        {

            this.BackColor = DefaultBackColor;

            gbColor.ForeColor = DefaultForeColor;

            rdoRed.Checked = false;

            rdoBlue.Checked = false;

            rdoGreen.Checked = false;

        }

 

        private void rdoGreen_Click(object sender, EventArgs e)

        {

            this.BackColor = Color.Green;

            gbColor.ForeColor = Color.Green;

            btnDefault.ForeColor = Color.Black;

        }

 

 

Coding of controls on tabPage2.

        private void treeView1_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)

        {

            TreeNode nName = e.Node;

            string webPage = "";

            webPage = (string)nName.Tag;

            if (webPage != "")

            {

                webBrowser1.Navigate(webPage);

            }

        }

 


Don't want to miss updates? Please click the below button!

Follow MindStick