Click here to Skip to main content
16,011,475 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have created a user-control containing radio-buttons,text-box,labels etc.
I want to add this control to window-Form on button click. I can add this control many times.
How Can i create its instances dynamically?

Thanks in Advance.
Posted
Updated 27-Mar-11 23:27pm
v2

1 solution

Use a List<T> of references to your user-control objects. Each time the button is clicked create a new instance of these objects and add the reference to your list. The object's constructor should contain all necessary steps to initialize the components. You could also add a parameter to assign the List's index of the current object.
 
Share this answer
 
Comments
Ashwani Dhiman 28-Mar-11 5:44am    
Thanks.
Apfelmuuus 28-Mar-11 5:50am    
No problem;-)

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