Click here to Skip to main content
15,892,480 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to add one user control to another user control??
Say UserControl1 and UserControl2.
I want to add the UserControl2 to UserControl1.
How can I do It??
Posted
Comments
BillWoodruff 30-Mar-15 5:15am    
Do you mean how to add a UserControl2 to UserControl1 by drag-dropping at design-time ? Or, at run-time using code ?

1 solution

UserControl1.Controls.Add(UserControl2) - replace typenames with real instances

If these are UI controls you should be able to add one to the other by dragging them onto designer surface.

This should do the trick
C#
UserControl2 u2 = new UserControl2
UserControl1 u1 = new Usercontrol1

u1.Controls.Add(u2)


It is just the same as if you're adding a button or textbox.
 
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