Public Class CustomControl1
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
MyBase.OnPaint(e)
'Add your custom paint code here
Dim rect As Rectangle = Me.ClientRectangle
Dim drawPen As New Pen(Color.Blue, 2)
e.Graphics.DrawRectangle(drawPen, rect)
Dim drawBrush As New System.Drawing.Drawing2D.LinearGradientBrush( _
rect, Color.Blue, Color.Gold, 45)
e.Graphics.FillRectangle(drawBrush, rect)
End Sub
End Class
Public Class MainForm
Private WithEvents obj2 As CustomControl1
Private Sub MainForm_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
obj2 = New CustomControl1
obj2.Location = Me.Location + New Point(30, 30)
obj2.Size = New Size(60, 60)
obj2.Visible = False
End Sub
End Class
'Required by the Control Designer
Private components As System.ComponentModel.IContainer
' NOTE: The following procedure is required by the Component Designer
' It can be modified using the Component Designer. Do not modify it
' using the code editor.
_
Private Sub InitializeComponent()
components = New System.ComponentModel.Container()
End Sub
|