Click here to Skip to main content
15,894,825 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my Code

C#
namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private List<textbox> inputTextBoxes;
        public Form1()
        {
            InitializeComponent();
            this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
            this.AutoSize = true;
            this.Padding = new Padding(0, 0, 20, 20);
            this.StartPosition = FormStartPosition.CenterScreen;
        }

        private void btnadd_Click(object sender, EventArgs e)
        {
            int inputNumber = Int32.Parse(textBox1.Text);
            inputTextBoxes = new List<textbox>();
            inputTextBoxes = new List<textbox>();

            for (int i = 1; i <= inputNumber; i++)
            {
                Label labelInput = new Label();
                TextBox textBoxNewInput = new TextBox();
                labelInput.Text = " " + i;
                labelInput.Location = new Point(30, textBox1.Bottom + (i * 30));
                labelInput.AutoSize = true;
                textBoxNewInput.Location = new Point(labelInput.Width, labelInput.Top - 3);
                inputTextBoxes.Add(textBoxNewInput);
                this.Controls.Add(labelInput);
                this.Controls.Add(textBoxNewInput);
           }
          
        }
       
    }

But i want Three column Heading like S.No,Name,Destination and rows based on the value entered in the text box
Posted
Updated 25-Aug-15 21:37pm
v2

1 solution

Then you probably need to create fixed width labels and position them at the top of the form. Then for each row you add the three textboxes at the relative points below the labels. Or you could make life easy for yourself and use a DataGridView[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900