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

  • Home
  • SEARCH
  • 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 6653961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:19:59+00:00 2026-05-26T01:19:59+00:00

I am trying to write a code in order to create dynamic textboxes. I

  • 0

I am trying to write a code in order to create dynamic textboxes.

I have Function class and have a second form in my program named ProductForm.cs

What I wanna do is to read some data with a function named GetSpecs in my Function.cs and than inside GetSpecs I want to call a function in another class and send data to my other function under ProductForm.cs class.

I am getting blank form at the end.

a part of my GetSpecs function:

private String GetSpecs(String webData)
{
   ......
   ProductForm form2 = new ProductForm();
   form2.CreateTextBox(n);
}

ProductForm.cs

public void CreateTextBox(int i)
    {
        ProductForm form2 = new ProductForm();
        form2.Visible = true;
        form2.Activate();

        int x = 10;
        int y = 10;
        int width = 100;
        int height = 20;

        for (int n = 0; n < i; n++)
        {
            for (int row = 0; row < 4; row++)
            {
                String name = "txtBox_" + row.ToString();
                TextBox tb = new TextBox();
                tb.Name = name;

                tb.Location = new Point(x, y);
                tb.Height = height;
                tb.Width = width + row * 2;
                x += 25 + row * 2;
                this.Controls.Add(tb);

            }
            y += 25;

        }

    }

I get a blank form of ProductForm. Textboxes are not created or I cannot see them.

If I put textbox inside

private void ProductForm_Load(object sender, EventArgs e)

I can see textboxes.

  • 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-26T01:19:59+00:00Added an answer on May 26, 2026 at 1:19 am

    You are adding the controls to the current form: this.Controls.Add(tb);, you need to add them to the other form:

    form2.Controls.Add(tb);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have create my code in order to write images in a remote sql
I'm trying to write a function that pulls the lowest order number out of
I'm trying to write a program to automate a ticket draft. We have a
I have built a .cpp program in order to write some content to a
I was trying to write code that would auto-close a Toplevel Tk window in
Really stuck on trying to write code to unzip a file or directory on
I'm trying to write code that will load an image from a resource, and
I've been trying to write code that loads a .png file, attaches hotspot information,
I'm trying to write some code to find a specific XmlNode object based on
I'm trying to write some code to work with an htdigest password file. The

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.