For example, if I want to do this
and my tab control is created in this method
How do I remove it?
Code:
private void ProcessLogin()
{
TabPage welcomeTab = new TabPage("Welcome");
welcomeTab.BackColor = SystemColors.Control;
tabControl1.TabPages.Remove(loginTab);
tabControl1.TabPages.Add(welcomeTab);
}
Code:
private void FirstLogin()
{
TabPage loginTab = new TabPage("Login");
loginTab.BackColor = SystemColors.Control;
tabControl1.TabPages.Add(loginTab); // add the tab
Label loginLabel = new Label();
loginLabel.Text = "You are required to log in before you can access the system.";
loginLabel.AutoSize = true;
Label userName = new Label();
userName.Text = "Username: ";
userName.AutoSize = true;
userName.Location = new System.Drawing.Point(0, 30);
TextBox userTB = new TextBox();
userTB.Location = new System.Drawing.Point(61, 28);
userTB.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckKey);
Label password = new Label();
password.Text = "Password: ";
password.AutoSize = true;
password.Location = new System.Drawing.Point(0, 60);
TextBox userPass = new TextBox();
userPass.Location = new System.Drawing.Point(61, 58);
userPass.PasswordChar = '*';
userPass.KeyPress += new System.Windows.Forms.KeyPressEventHandler(CheckKey);
Button loginButton = new Button();
loginButton.Location = new System.Drawing.Point(0, 90);
loginButton.Text = "Login";
loginButton.Click += new System.EventHandler(loginButton_Click);
loginTab.Controls.Add(loginLabel);
loginTab.Controls.Add(userName);
loginTab.Controls.Add(userTB);
loginTab.Controls.Add(userPass);
loginTab.Controls.Add(password);
loginTab.Controls.Add(loginButton);
}
Comment