You don't necessarily need to put the custom control in another library, unless you want to use it in multiple projects. If it's just one Windows Forms project, you can easily add different types of control to the project (including new User Control or Custom control or any class which is deriving from a Control) and after a build if you open a Form in design mode, the control appears in ToolBox.
If you are looking for creating a Windows Forms library to have some controls which you can reference in other project, read the rest of the answer.
Windows Forms Control/Class Library - .NET 6
You are looking for either of the following, targeting .NET (not .NET Framework):
- Windows Forms Class Library
- Windows Forms Control Library
Both project templates will create the same project type:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
</Project>
The only difference is the Control Library project contains a UserControl1, but the Class Library contains Class1.
Example - Creating and using a Windows Forms Control/Class Library - .NET 6
- Create a new project or type Windows Forms (not .NET Framework) and choose .NET 6 as the framework, choose
WinFormsApp1
as the name of the project - Create a new project or type Windows Forms Control Library (not .NET Framework) and choose .NET 6 as the framework, choose
WinFormsControlLibrary1
as the name of the project - Right click on
Dependencies
ofWinFormsApp1
, and click on Add Project Reference ... and checkWinFormsControlLibrary1
as the reference. - Close all designers and Rebuild the solution.
- Double click on
Form1
inWinFormsApp1
to open it in designer. - Open toolbox, and drop an instance of
UserControl1
on the form.