I am just wondering if I did this the best way possible. I needed to
add a double boarder around a label box. So I made a pen in the class,
and do the drawing of the rectangles in the onpaint method. Did I do
the disposal right? Is there a better way to do this? Thanks
Chris
Public Class ErrorMessageBox
Inherits Label
Dim m_Pen As Drawing.Pen
Sub New()
m_Pen = New Drawing.Pen(Color.Black)
End Sub
Private Overloads Sub dispose()
m_Pen.Dispose()
MyBase.dispose()
End Sub
Protected Overrides Sub OnPaint(ByVal e As
System.Windows.Forms.PaintEventArgs)
Dim StringSize As Drawing.SizeF =
e.Graphics.MeasureString(Me.Text, Me.Font)
Me.Width = CInt(StringSize.Width) + 40
Me.Height = CInt(StringSize.Height) + 40
Me.BringToFront()
MyBase.OnPaint(e)
e.Graphics.DrawRectangle(m_Pen, 3, 3, Me.Width - 6, Me.Height - 6)
e.Graphics.DrawRectangle(m_Pen, 5, 5, Me.Width - 10, Me.Height
- 10)
End Sub
End Class