Example with TabControl:-



Add a new Form i.e.,FormTabControl to the Windows Application WABasics
Create two labels,one textbox and one tabControl ,eight CheckBoxes& set the following properties to them
[imageList1,timer1 will only appear in the Component Tray]


label1:
     Text      : Enter Any Data
     Name   : lblSample


label2:
     Text     :WelCome
     Name   : lblWelcome

textbox1:
     Name   : txtSample



tabPage1:-
Name       :   tabPage1

TabPages :   click on Ellipsis button ,this will open the TabPage Collectin Editor—Click on Add to Add the TabPages---Give name to Tabpages using Name propertie in Tabpage Collection Editor---After Adding tabPages Ckick on Ok



checkBox1:-
     Text       : Red
     Name     : optRed

checkBox21:-
     Text       : Green
     Name     : optGreen

checkBox3:-
     Text       : Blue
     Name     : optBlue

checkBox4:-
     Text       : White
     Name     : optWhite

checkBox5:-
     Text       : Cyan
     Name     : optCyan

checkBox6:-
     Text       : Gold
     Name     : optGold

checkBox7:-
     Text       : Yellow
     Name     : optYellow

checkBox8:-
     Text       : Black
     Name     : optBlack


Design :-




  •  Generate theEventHandlers  optRed,optGreen,optBlue,optWhite,optCyan,optGold,optYellow,optBlack  CheckBoxes CheckedChanged Events
  • Generate the EventHandlers for btnPrevious,btnNext Buttons Click Events
  •  write the following code in Source[FormTabControl.cs] 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WABasics
{
    public partial class FormTabControl : Form
    {
        public FormTabControl()
        {
            InitializeComponent();
        }

        private void optRed_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.BackColor = Color.Red;
        }

        private void optGreen_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.BackColor = Color.Green;
        }

        private void optBlue_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.BackColor = Color.Blue;

        }

        private void optWhite_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.BackColor = Color.White;
        }

        private void btnNext_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = tabControl1.SelectedIndex + 1;
        }

        private void Cyan_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.ForeColor = Color.Cyan;
        }

        private void optGold_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.ForeColor = Color.Gold;
        }

        private void Yellow_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.ForeColor = Color.Yellow;
        }

        private void optBlack_CheckedChanged(object sender, EventArgs e)
        {
            txtSample.ForeColor = Color.Black;
        }

        private void btnPrevious_Click(object sender, EventArgs e)
        {
            tabControl1.SelectedIndex = tabControl1.SelectedIndex - 1;
        }
       
    }
}


Result :-



No comments:

Post a Comment