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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T12:01:25+00:00 2026-05-11T12:01:25+00:00

I have to create variable number of Labels and next to them TextBox controls

  • 0

I have to create variable number of Labels and next to them TextBox controls – arranging the whole thing into a column, each line a Label and a TextBox. If the my Main window is smaller than the total height of all the TextBox controls, somehow I need a scrollbar which can scroll the list of TextBoxes. Pressing the enter key would have to take the focus to the next TextBox and also scroll in case of too many TextBoxes.

This is a rather generic problem, I guess there are already some pre-baked solutions for this.

Any advice?

  • 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. 2026-05-11T12:01:25+00:00Added an answer on May 11, 2026 at 12:01 pm

    You can use TableLayoutPanel as container for controls (Labels and TextBoxes) and create them dynamicaly in code.

    Example:

    void Form1_Load( object sender, EventArgs e ) {     const int COUNT = 10;      TableLayoutPanel pnlContent = new TableLayoutPanel();     pnlContent.Dock = DockStyle.Fill;     pnlContent.AutoScroll = true;     pnlContent.AutoScrollMargin = new Size( 1, 1 );     pnlContent.AutoScrollMinSize = new Size( 1, 1 );     pnlContent.RowCount = COUNT;     pnlContent.ColumnCount = 3;     for ( int i = 0; i < pnlContent.ColumnCount; i++ ) {         pnlContent.ColumnStyles.Add( new ColumnStyle() );     }     pnlContent.ColumnStyles[0].Width = 100;     pnlContent.ColumnStyles[1].Width = 5;     pnlContent.ColumnStyles[2].SizeType = SizeType.Percent;     pnlContent.ColumnStyles[2].Width = 100;      this.Controls.Add( pnlContent );      for ( int i = 0; i < COUNT; i++ ) {         pnlContent.RowStyles.Add( new RowStyle( SizeType.Absolute, 20 ) );          Label lblTitle = new Label();         lblTitle.Text = string.Format( 'Row {0}:', i + 1 );         lblTitle.TabIndex = (i * 2);         lblTitle.Margin = new Padding( 0 );         lblTitle.Dock = DockStyle.Fill;         pnlContent.Controls.Add( lblTitle, 0, i );          TextBox txtValue = new TextBox();         txtValue.TabIndex = (i * 2) + 1;         txtValue.Margin = new Padding( 0 );         txtValue.Dock = DockStyle.Fill;         txtValue.KeyDown += new KeyEventHandler( txtValue_KeyDown );         pnlContent.Controls.Add( txtValue, 2, i );     } }  void txtValue_KeyDown( object sender, KeyEventArgs e ) {     if ( e.KeyCode == Keys.Enter ) {         SendKeys.Send( '{TAB}' );     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to dynamically create a table with a variable number of columns, determined
In Python I have a list of n lists, each with a variable number
Hi I have the following requirement. I want to create variable number of String
I have an app that creates a variable number of ScatterviewItems based on which
I have been playing around with GC.GetTotalMemory(). When I create a local variable of
I have a javascript function create(tagName, options) and the options variable is a JSON
Lets say in a dialog, we dynamically create a variable number of CWnds... like
I am working to create functional OK and Cancel buttons for a variable number
I have a JSF page which has a variable number inputText elements containing numeric
Does anyone have any examples on how to create a dynamic number of TextInput

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.