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 6192475
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:56:59+00:00 2026-05-24T02:56:59+00:00

I need to add some controls dynamically, As the number of elements in my

  • 0

I need to add some controls dynamically, As the number of elements in my array, how can I put in a dynamic and place them in order, for example I have this controls And I have to double them ,this code I have to double

 this.label1 = new System.Windows.Forms.Label();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.label2 = new System.Windows.Forms.Label();
        this.label3 = new System.Windows.Forms.Label();
        this.label4 = new System.Windows.Forms.Label();
        this.label5 = new System.Windows.Forms.Label();
        this.textBox2 = new System.Windows.Forms.TextBox();
        this.textBox3 = new System.Windows.Forms.TextBox();
        this.SuspendLayout();
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(685, 80);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(23, 13);
        this.label1.TabIndex = 0;
        this.label1.Text = "name";
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(507, 77);
        this.textBox1.Name = "textBox1";
        this.textBox1.Size = new System.Drawing.Size(156, 20);
        this.textBox1.TabIndex = 1;
        // 
        // label2
        // 
        this.label2.AutoSize = true;
        this.label2.Location = new System.Drawing.Point(401, 79);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(91, 13);
        this.label2.TabIndex = 2;
        this.label2.Text = "age";
        // 
        // label3
        // 
        this.label3.AutoSize = true;
        this.label3.Location = new System.Drawing.Point(290, 79);
        this.label3.Name = "label3";
        this.label3.Size = new System.Drawing.Size(28, 13);
        this.label3.TabIndex = 3;
        this.label3.Text = "old";
        // 
        // label4
        // 
        this.label4.AutoSize = true;
        this.label4.Location = new System.Drawing.Point(184, 79);
        this.label4.Name = "label4";
        this.label4.Size = new System.Drawing.Size(82, 13);
        this.label4.TabIndex = 4;
        this.label4.Text = "sum";
        // 
        // label5
        // 
        this.label5.AutoSize = true;
        this.label5.Location = new System.Drawing.Point(83, 78);
        this.label5.Name = "label5";
        this.label5.Size = new System.Drawing.Size(28, 13);
        this.label5.TabIndex = 5;
        this.label5.Text = "$";
        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(335, 77);
        this.textBox2.Name = "textBox2";
        this.textBox2.Size = new System.Drawing.Size(44, 20);
        this.textBox2.TabIndex = 6;
        // 
        // textBox3
        // 
        this.textBox3.Location = new System.Drawing.Point(125, 77);
        this.textBox3.Name = "textBox3";
        this.textBox3.Size = new System.Drawing.Size(44, 20);
        this.textBox3.TabIndex = 7;
        // 
        // Form2
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(751, 428);
        this.Controls.Add(this.textBox3);
        this.Controls.Add(this.textBox2);
        this.Controls.Add(this.label5);
        this.Controls.Add(this.label4);
        this.Controls.Add(this.label3);
        this.Controls.Add(this.label2);
        this.Controls.Add(this.textBox1);
        this.Controls.Add(this.label1);

Sorry if that’s too long, how can i do it?

  • 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-24T02:57:00+00:00Added an answer on May 24, 2026 at 2:57 am

    You can add many controls without specifying the name. for instance:

    private void DynamicAddTextBoxes(Point startLocation, count)
    {
        Point location = startLocation;
        for (int textBoxIndex = 0; textBoxIndex < count; textBoxIndex++)
        {
            TextBox textBox = new TextBox();
            textBox.Text = textBoxIndex.ToString();
            textBox.Location = new Point(location.X, location.Y + 50);
            this.Controls.Add(textBox );
        }
    }
    

    This code will add sequence of TextBoxes to the form.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Custom Canvas(DesignerCanvas), user can add some controls to this canvas. Before
I need to add onclick event to some dynamically added button , but when
I need to add some controls to context menu. Is it possible? If yes,
I understand the page lifecycle and how I need to add the dynamic controls
i need to add JavaScript calls in some controls attributes, i am using master
I am making a custom control I need to add some default keybindings, microsoft
I need to add some accordian style expand/collapse handles to a series of parent
I need to add some lightweight syntactic sugar to JavaScript source code, and process
i need to add some text DIV's on each slide of a Nivoslider. I
i need to add some functionality to an asp.net application that allows the positioning

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.