Home > DeveloperSection > Articles > Creating and using Windows Forms Control Library in C#.Net

Creating and using Windows Forms Control Library in C#.Net

Windows Controls Windows Controls 
0 Comment(s)
 41184  View(s)
Rate this:

Creating and using Windows Forms Control Library (User Control) in C#.net

Creating user control




To create User Control in C# select “Windows Forms Control Library” icon from New Project Dialog Box.

Add some controls and add codes for the controls in User Control.




private void btnColour_Click(object sender, EventArgs e)


//this will change the color of form on which this control is placed.

           this.ParentForm.BackColor= Color.Red;


Now once the control is created we need to built it in order to use in other projects.

Using User Control in project

To use user control in our project we need to add that control in project. To add right click on Toolbox and select “Choose Items”

A dialog box “Choose Toolbox Items” will appear. In that dialog box click browse button and select user control created earlier from bin\debug folder of user control project, then press Ok.

User control will be added to the project toolbox.

Now we can use the user control. 



 Screen shot after Execution

Color of the form changes on button click without doing any coding in the current form. On button click code of user control is executed.

Don't want to miss updates? Please click the below button!

Follow MindStick