Protected Sub DrawText(ByVal gpcs As Graphics, ByVal br As Brush, ByVal s As String, ByVal R As RectangleF, ByVal ss As System.Drawing.StringFormat)
Dim ff As Font = New System.Drawing.Font("Arial", 10)
Dim hj As SizeF = gpcs.MeasureString(s, ff, New SizeF(R.Width, R.Height), ss)
gpcs.DrawString(s, ff, br, R, ss)
Dim RT As Integer
Select Case ss.LineAlignment
Case StringAlignment.Near
RT = R.Top
Case StringAlignment.Center
RT = R.Top + R.Height / 2 - hj.Height / 2
Case StringAlignment.Far
RT = R.Bottom - hj.Height
End Select
Dim RL As Integer
Select Case ss.Alignment
Case StringAlignment.Near
RL = R.Left
Case StringAlignment.Center
RL = R.Left + R.Width / 2 - hj.Width / 2
Case StringAlignment.Far
RL = R.Right - hj.Width
End Select
TextRect = New Rectangle(RL, RT, hj.Width, hj.Height)
End Sub