Hello,

Could you please tell me since I spent so much time on this, how to create multiple text boxes based on the selected combo box value (eg. 1,2,3,4,5....). I tried for loop but I only get one text box created. Basically if I select value 4 from the combo box I would need 4 text boxes created and so on....
Any help is greatley appreciated. Thanks

Try this code:

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int count =int.Parse( comboBox1.SelectedItem.ToString());
            TextBox[] t=new TextBox[count];
            int x = 70, y = 50;
            for (int i = 0; i < count; i++)
            {
                t[i]=new TextBox();
                t[i].Location = new System.Drawing.Point(x,y);
                t[i].Size = new Size(20, 20);
                t[i].TabIndex = 1;
                this.Controls.Add(t[i]);
                this.ResumeLayout(false);
                y += 40;
            }
        }

Edited 6 Years Ago by tweety1313: n/a

Thanks alot tweety1313, this actually makes sense. I'll try it as soon as I come home.

Thanks alot tweety1313, this actually makes sense. I'll try it as soon as I come home.

And it works, perfect....thanks again!

how to use ComboBox set value to TextFields and there are more than one text field and every textfield has different value from the other text fields if there is one text field combobox can set the value in it but if there is more than one textfield combobox insert the same value in it

This question has already been answered. Start a new discussion instead.