Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6830413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:36:53+00:00 2026-05-26T22:36:53+00:00

I have a form where I can add tabs into a tabcontrol by pressing

  • 0

I have a form where I can add tabs into a tabcontrol by pressing a button on the form. There are 4 textboxes and then the name of the tab. I have added using system.io;

Where would I even start to create a save for all of the tabs? I have the save button created, I just don’t know where to start. I would guess I would need a loop of some kind.

namespace WindowsFormsApplication4
{
    public partial class Form1 : Form
    {
        public string status = "no";

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string name = txtName.Text;


            //validate information
            try { }
            catch { }

            //create new tab
            string title = name;
            TabPage myTabPage = new TabPage(title);
            tabControl1.TabPages.Add(myTabPage);


            //Add Labels

            Label lb = new Label();
            lb.Text = "Denomination:";
            lb.Location = new System.Drawing.Point(150, 75);
            lb.Name = "lbl";
            lb.Size = new System.Drawing.Size(100, 20);
            myTabPage.Controls.Add(lb);

            Label lb2 = new Label();
            lb2.Text = "Year:";
            lb2.Location = new System.Drawing.Point(150, 120);
            lb2.Name = "lbl2";
            lb2.Size = new System.Drawing.Size(100, 20);
            myTabPage.Controls.Add(lb2);

            Label lb3 = new Label();
            lb3.Text = "Grade:";
            lb3.Location = new System.Drawing.Point(150, 165);
            lb3.Name = "lbl3";
            lb3.Size = new System.Drawing.Size(100, 20);
            myTabPage.Controls.Add(lb3);

            Label lb4 = new Label();
            lb4.Text = "Mint Mark:";
            lb4.Location = new System.Drawing.Point(150, 210);
            lb4.Name = "lbl4";
            lb4.Size = new System.Drawing.Size(100, 20);
            myTabPage.Controls.Add(lb4);

            //Add text boxes

            TextBox tb = new TextBox();
            tb.Location = new System.Drawing.Point(250, 75);
            tb.Name = "txt";
            tb.Size = new System.Drawing.Size(184, 20);
            myTabPage.Controls.Add(tb);

            TextBox tb1 = new TextBox();
            tb1.Location = new System.Drawing.Point(250, 120);
            tb1.Name = "txt1";
            tb1.Size = new System.Drawing.Size(184, 20);
            myTabPage.Controls.Add(tb1);

            TextBox tb2 = new TextBox();
            tb2.Location = new System.Drawing.Point(250, 165);
            tb2.Name = "txt2";
            tb2.Size = new System.Drawing.Size(184, 20);
            myTabPage.Controls.Add(tb2);

            TextBox tb3 = new TextBox();
            tb3.Location = new System.Drawing.Point(250, 210);
            tb3.Name = "txt3";
            tb3.Size = new System.Drawing.Size(184, 20);
            myTabPage.Controls.Add(tb3);

            //put data inside of textboxes

            tb.Text = txtCoin.Text;
            tb1.Text = txtYear.Text;
            tb2.Text = txtGrade.Text;
            tb3.Text = txtMint.Text;

            // Add delete button

            Button bn = new Button();
            bn.Location = new System.Drawing.Point(560, 350);
            bn.Name = "btnDelete";
            bn.Text = "Delete";
            bn.Size = new System.Drawing.Size(100, 50);
            bn.Click += MyClick;
            myTabPage.Controls.Add(bn);
        }

        private void MyClick(object sender, EventArgs e)
        {
            Form2 myform = new Form2();
            myform.ShowDialog();




            if (status == "yes")
            { tabControl1.TabPages.Remove(tabControl1.SelectedTab); }

            status = "no";

        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {

            int counter;
            int ccounter;
            string outLine;

            string pathFileName = Path.Combine(Application.StartupPath, "coins.dat");

            StreamWriter writeIt = new StreamWriter(pathFileName);

            for (counter = 0; ((tabControl1.TabCount) -1) != 0 ;)
            {

            }
            writeIt.Close();

        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:36:54+00:00Added an answer on May 26, 2026 at 10:36 pm

    Use a foreach loop instead of your for (counter = 0; ((tabControl1.TabCount) -1) != 0 ;) loop:

    foreach (TabPage tabPage in tabControl.TabPages)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form a user can enter their name, then it will add
I have a form into which the user can add more fields to fill
I have a form which users can add controls to and when they right
I have a form where users can add input fields with jQuery. <input type="text"
I have form, where some fields are looks like rows, so I can add/delete
I have a form in witch users can add their working hours view them
I have a form where user can add and position charts and controls for
I have a form where a user can add multiple select boxes for multiple
I have a form where at some point you can add multiple rows of
I have a form that people can add their stuff. However, in that form,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.