I want to compile a DLL control, is a Extended Panel but I only have the class, I don't like to use classes for add a custom control, i prefer to add the DLL into the toolbox.
Someone can help me to transform this into a class library DLL control?
PS: In addition maybe I can need a guide-step to make the class-library too, it's my first time trying this.
Thankyou.
Imports System
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Text
Imports System.Windows.Forms
Namespace GradientPanel
Public Partial Class GradientPanel
Inherits System.Windows.Forms.Panel
' member variables
Private mStartColor As System.Drawing.Color
Private mEndColor As System.Drawing.Color
Public Sub New()
' InitializeComponent()
PaintGradient()
End Sub
Protected Overrides Sub OnPaint(pe As PaintEventArgs)
' TODO: Add custom paint code here
' Calling the base class OnPaint
MyBase.OnPaint(pe)
End Sub
Public Property PageStartColor() As System.Drawing.Color
Get
Return mStartColor
End Get
Set
mStartColor = value
PaintGradient()
End Set
End Property
Public Property PageEndColor() As System.Drawing.Color
Get
Return mEndColor
End Get
Set
mEndColor = value
PaintGradient()
End Set
End Property
Private Sub PaintGradient()
Dim gradBrush As System.Drawing.Drawing2D.LinearGradientBrush
gradBrush = New System.Drawing.Drawing2D.LinearGradientBrush(New Point(0, 0), New Point(Me.Width, Me.Height), PageStartColor, PageEndColor)
Dim bmp As New Bitmap(Me.Width, Me.Height)
Dim g As Graphics = Graphics.FromImage(bmp)
g.FillRectangle(gradBrush, New Rectangle(0, 0, Me.Width, Me.Height))
Me.BackgroundImage = bmp
Me.BackgroundImageLayout = ImageLayout.Stretch
End Sub
End Class
End Namespace
I have always just used a CustomControlLibrary Name it and set the Assembly Name and Default Namespace to what you want the dll to be, you will then right click on the project and select add class then you will add your Custom Control's Class Code to the the Project. You can also add a new UserControl at that time. When you compile it, it will create a dll that you can browse to by right clicking on your ToolBox selecting choose items then Browse to your Dll that was created. It will then add the Controls that are contained in your Control Library to your ToolBox.