Imports System.Windows.Forms Imports System.Drawing Module Module1 Public Sub main() Application.Run(New MainForm()) End Sub End Module Class MainForm Inherits Form Dim pb As CustomPictureBox Public Sub New() pb = New CustomPictureBox() pb.Dock = DockStyle.Fill Me.Controls.Add(pb) AddHandler pb.Paint, New PaintEventHandler(AddressOf DrawBackGround) AddHandler pb.Paint, New PaintEventHandler(AddressOf drawBlackRect) AddHandler pb.Paint, New PaintEventHandler(AddressOf drawRedRect) End Sub Sub DrawBackGround(ByVal sender As Object, ByVal e As PaintEventArgs) e.Graphics.FillRectangle(Brushes.White, e.ClipRectangle) End Sub Sub drawBlackRect(ByVal sender As Object, ByVal e As PaintEventArgs) e.Graphics.FillRectangle(Brushes.Black, New RectangleF(10, 10, 100, 100)) End Sub Sub drawRedRect(ByVal sender As Object, ByVal e As PaintEventArgs) e.Graphics.FillRectangle(Brushes.Red, New RectangleF(20, 20, 100, 100)) End Sub End Class Class CustomPictureBox Inherits PictureBox Public Shadows Custom Event Paint As PaintEventHandler AddHandler(ByVal value As PaintEventHandler) EventList.Add(value) End AddHandler RemoveHandler(ByVal value As PaintEventHandler) EventList.RemoveAt(EventList.LastIndexOf(value)) End RemoveHandler RaiseEvent(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) For Each method As PaintEventHandler In EventList method(sender, e) Next End RaiseEvent End Event Private EventList As New List(Of PaintEventHandler) Sub basePaint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint RaiseEvent Paint(sender, e) End Sub End Class