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 ttr { public partial class Form1 : Form { public Form1() { InitializeComponent(); tabControl1.Visible = false; } private void button1_Click(object sender, EventArgs e) { tabControl1.Visible = true; var contentControl = new tta(); contentControl.Dock = DockStyle.Fill; var page = new TabPage("Languages"); page.Controls.Add(contentControl); //tabControl1.TabPages.Clear(); tabControl1.TabPages.Add(page); tabControl1.SelectedTab = page; button1.Visible = true; button2.Visible = true; } private void button2_Click(object sender, EventArgs e) { tabControl1.Visible = true; var contentControl = new hhh(); contentControl.Dock = DockStyle.Fill; var page = new TabPage("Education"); page.Controls.Add(contentControl); tabControl1.SelectedTab = page; //tabControl1.TabPages.Clear(); tabControl1.TabPages.Add(page); button1.Visible = true; button2.Visible = true; } } }
//Declare at class level. TabPage languagesPage = null; TabPage educationPage = null; //Put this check before initializing the object. Do the same for other tab too. if(educationPage == null) { educationPage = new TabPage("Education"); page.Controls.Add(contentControl); tabControl1.TabPages.Add(page); } tabControl1.SelectedTab = educationPage ;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)