C# TabControl
The TabControl manages tab pages where each page
may host different child controls.
The .NET Framework provides this versatile and easy-to-use control. We add the control, change its pages, manipulate it in C# code, and change its visual settings.
TabPages.
Adjusting the TabPages in the TabControl is important. This mechanism allows you to add a variable number of pages to your tab control.DEMO
C# CODING
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApplication2
{
public partial class TabControl : Form
{
public TabControl()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
tabControl1.SelectTab("tabPage2");
// OR
tabControl1.SelectedIndex = 1;
tabPage2.BackColor = Color.Green;
}
private void button2_Click(object sender, EventArgs e)
{
tabControl1.SelectTab("tabPage3");
// OR
tabControl1.SelectedIndex = 2;
tabPage3.BackColor = Color.Red;
}
private void button3_Click(object sender, EventArgs e)
{
tabControl1.SelectTab("tabPage1");
// OR
tabControl1.SelectedIndex = 0;
tabPage1.BackColor = Color.Pink;
}
}
}
0 comments:
Post a Comment