Click here to Skip to main content
16,021,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
aam developing a windows app, i want that on clicking a button textboxes will be created with names textBox1,textBox2,textBox3....i am able to create textboxes and add it form, but i want the names to be dynamic e.g
int count=1;
string name="textBox"+count.ToString();
TextBox name=new TextBox();
But its not working........please help
Posted

1 solution

First thing, you can't use same name but once.. In your code,
int count=1;
string name="textBox"+count.ToString();
TextBox name=new TextBox();

name is used twice...

and, try this as your solution..
int count=1;
string str="textBox"+count.ToString();
TextBox nameTxt=new TextBox();
nameTxt.Text = str ;
 
Share this answer
 
Comments
Himu from Orissa 12-Dec-12 7:50am    
thats ok , but can i add textboxes with names textBox1,textBox2...
[no name] 12-Dec-12 7:51am    
Yes you can..

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