Click here to Skip to main content
16,020,714 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please any one tell me how to create multiple textboxes? It means one Texbox is there, and suppose we enter "3" in that textbox, then 3 textboxes should be created.

Please anybody help me.
Posted
Updated 19-Jun-11 21:46pm
v3
Comments
Abhinav S 20-Jun-11 3:21am    
Email id removed.

dynamically controls generation

for (int j = 1; j <= Convert.ToInt32(txtNoOFControl.text); j++)
{
    TextBox txt = new TextBox();
    txt.Size = new Size(34, 24);
    txt.Location = new Point(((j % 20) * 34), (j / 20 * 34));
    txt.Text = j.ToString();
    txt.TabIndex = j;
    txt.Visible = true;
    this.Controls.Add(txt);
}
 
Share this answer
 
Comments
gauravrank 20-Jun-11 3:48am    
Unable to cast object of type 'System.Windows.Forms.TextBox' to type 'System.IConvertible'.

this error are occured
Tarun.K.S 20-Jun-11 3:52am    
It should help. 5+
You need to create textboxes dynamically based on the count of the first textbox as below.
for (int i;i <= int.Parse(mytextbox.text);i++)
{
          System.Windows.Forms.TextBox textbox = new System.Windows.Forms.TextBox();
      textbox.Name = "textbox"+i.ToString();
      textbox.TabIndex = i;
      textbox.Visible = true;
          Controls.Add(textbox);
}
 
Share this answer
 
v3
Comments
gauravrank 20-Jun-11 3:28am    
abhinav bhai that is not work pls help me..
gauravrank 20-Jun-11 3:34am    
operator '<=' cannot be applied to operand of type 'int' or 'string'.


this error are occured pls help me
jayantbramhankar 20-Jun-11 3:38am    
Parse textbox value to int

for (int i;i<= int.Parse(mytextbox.text);i++)
gauravrank 20-Jun-11 3:49am    
jayant bhai that is not worked i try it
Tarun.K.S 20-Jun-11 3:48am    
Updated the answer by Parsing the string.

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