You can create a new user control with the Project|Add User Control menu item, or by creating a new project based on a user control by selecting the File|New|Project menu item, then selecting the Windows Control Library icon and clicking OK.
We saw an example showing how to create a new user control with properties, methods, and events in the UserControls example, as discussed in the In Depth section of this chapter. You can see this user control at work in Figure 24.5; here is the code for the user control in that example, UserControl1.vb (without the Windows Form Designer generated code):
Public Class UserControl1 Inherits System.Windows.Forms.UserControl ' Windows Form Designer generated code... Private LabelColor As Color Public Event TextModified(ByVal NewText As String) Property DisplayColor() As Color Get Return LabelColor End Get Set(ByVal Value As Color) LabelColor = Value Label1.BackColor = LabelColor End Set End Property Public Sub SetText(ByVal NewText As String) Label1.Text = NewText RaiseEvent TextModified(NewText) End Sub End Class
For more information, see the In Depth section of this chapter, and the next few sections.