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
private void btnColour_Click(object
sender, EventArgs e)
change the color of form on which this control is placed.
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.