Click here to Skip to main content
15,922,325 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Dear friends,

I am developing a windows application in which i want to create 8 textboxes and a button dynamically (on run time-on click event of a button).

Can anybody help me for same.

Thanks in advance.
Shailesh J.
:-)
Posted

Try:
C#
for (int i = 0; i < 8; i++)
   {
   TextBox tb = new TextBox();
   Controls.Add(tb);
   }
Button but = new Button();
Controls.Add(but);
You will have to set the Location, Text and size of the various controls yourself, but that is up to you - I don't know how you want to arrange them.
 
Share this answer
 
Comments
saj_21 2-Jun-12 5:06am    
can i use flowlayout for same? I think it will help me to arrange them dynamically.
:-)
OriginalGriff 2-Jun-12 5:26am    
Yes - just put the name of your FlowLayoutPanel in front of the Controls property:
myFlowLayoutPanel.Controls.Add(...
 
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