Public Class Form1 ' Draw some text. Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint Dim x As Integer = 10 Dim y As Integer = 10 Using the_font As New Font("Times New Roman", 20, FontStyle.Bold, GraphicsUnit.Point) e.Graphics.DrawString("SimpleText", the_font, Brushes.Blue, x, y) Dim text_size As SizeF = e.Graphics.MeasureString("SimpleText", the_font) e.Graphics.DrawRectangle(Pens.Red, x, y, text_size.Width, text_size.Height) y += text_size.Height End Using Using the_font As New Font("Comic Sans MS", 20, FontStyle.Regular, GraphicsUnit.Point) e.Graphics.DrawString("SimpleText", the_font, Brushes.Blue, x, y) Dim text_size As SizeF = e.Graphics.MeasureString("SimpleText", the_font) e.Graphics.DrawRectangle(Pens.Red, x, y, text_size.Width, text_size.Height) y += text_size.Height End Using Using the_font As New Font("Arial", 20, FontStyle.Italic Or FontStyle.Bold, GraphicsUnit.Point) e.Graphics.DrawString("SimpleText", the_font, Brushes.Blue, x, y) Dim text_size As SizeF = e.Graphics.MeasureString("SimpleText", the_font) e.Graphics.DrawRectangle(Pens.Red, x, y, text_size.Width, text_size.Height) y += text_size.Height End Using End Sub End Class |