Calling Another user control from one

Generally on forum I have seen so many times same question has been asked, “How to call One user control from another user control

Lets See how to do that

User controls are always found in project “WindowsFormsControlLibrary”, whenever we have to make new user controls we have to add this project to our current project.

Our aim is to take one user control on form on form load and calling other one from same

  1. Add windowsFormsControlLibrary project to our C# project
  2. Add reference of windowsFormsControlLibrary project to our Forms project and add name space for same
  3. And on form load do following

              UserControl1 first = new UserControl1();
               this.Controls.Add(first);
     
  4. Now suppose there is a button on UserControl1 and we need to call another user control having name usercontrol2 and also UserControl1 should not visible to do so write on button click event of UserControl1

            UserControl2 second = new UserControl2();
            this.Hide();//because usercontrols have not Close() property as forms
            this.Parent.Controls.Add(second);