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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:46:42+00:00 2026-06-16T19:46:42+00:00

I have a usercontrol containing a panel , it contains two set of Textboxes

  • 0

screen shot of multiline text
I have a usercontrol containing a panel , it contains two set of Textboxes one for name and another for comments, I create the Textboxes dynamically then I hide the textbox used for commenting.

Here I am not able to show it on click event , I tried using a function called Textbox() , but it adds the comment box just for the first row.

This is the code for creating textbox in usercontrol

public void Textbox()
{
   TextBox[] tb1 = new TextBox[10];
   for (int i = 0; i < 7; i++)
   {
     tb1[i] = new TextBox();
     tb1[i].Multiline = true;
     tb1[i].Height = 10;
     tb1[i].Name = i.ToString();
     tb1[i].Location = new Point(250 + i * 90, 82);
     tb1[i].Size = new System.Drawing.Size(80, 40);
     rowpanel.Controls.Add(tb1[i]);
   }
}

next,I do this

private void comment_btn_Click(object sender, EventArgs e)
{
   add.Textbox();
}

When I click comment_btn the comment textbox gets added to first row.
add is my usercontrol

As seen in the figure, when Add is Clicked ,Multiline textbox is added only to first row, I want it to be added to every row that is displayed on the panel, I just cant figure out how I go about doing 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-06-16T19:46:43+00:00Added an answer on June 16, 2026 at 7:46 pm

    You mention that it only generates a textbox for the first row, indicating you’re expecting the dynamically generated comments textboxes to display on multiple rows?

    The code you’ve got there will generate the text boxes on the same row in multiple columns. The likelihood is that all 7 of your textboxes are generating correctly but you can only see the first one as the 2nd onwards are outside the bounds of your panel.

    Changing the location line to

    tb1[i].Location = new Point(250, 82 + i * 50);
    

    will generate the textboxes on multiple rows rather than multiple columns and hopefully display what you are after. – Addition of screenshot indicates the above is not the problem.

    EDIT: If each of those rows of controls is an instance of your user control, then currently you’re only calling the Textbox() method on one of them which is why only one row is being added. You need to add a loop in your comment_btn_Click method which calls the Textbox() method on every control you’ve created.

    e.g. Assuming your collection of user controls is on a panel called show_pnl and assuming your user controls are of type TimeRecordingControl:

    private void comment_btn_Click(object sender, EventArgs e)
    {
        foreach(Control control in show_pnl.Controls)
        {
            TimeRecordingControl timeRecordingControl = control as TimeRecordingControl;
    
            if(timeRecordingControl != null)
            {
                timeRecordingControl.Textbox();
            }
        }
    }
    

    Also, consider naming your methods in a way that indicates what they do, i.e. CreateTextboxesForComments rather than just Textbox 🙂

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

Sidebar

Related Questions

I have a UserControl containing TextBoxes and ComboBoxes and this UserControl is contained in
I have a simple UserControl containing a ComboBox which is empty at first. The
I have a UserControl, containing a FormView, containing a DropDownList. The FormView is bound
I have UserControls containing other controls. I want that if I set a Foreground
I have a UserControl and it contains a Button . Now, in some Windows
I have an UserControl that contains a Button : <UserControl> <Button> </UserControl> I want
I have a UserControl which contains a TextBox . When my main window loads
I have a UserControl A which contains a dropdown a placeholder At runtime the
I have a UserControl with a Tab Control containing three tabs. Within the tabs
I have a simple UserControl containing Label, ComboBox and Button. In brief, it is

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.