Strings

Of course, deciding on a font is only half the fun. The real action is drawing strings after the font's been picked. For that, you use the DrawString method of the Graphics object:

Dim myfont As Font = New Font("Arial", 12)
' This will wrap at new line characters
g.DrawString("line 1" & vbCrLf & "line 2", myfont, _
Brushes.Black, 10, 10)
Table 5.1. Font and FontFamily Sizes (Sample Font Is Arial 12 Point at 96 dpi)
MeasureUnitsExampleDescription
FontFamily.GetEmHeightDesign Units2,048Base size, equivalent to Size
FontFamily.GetCellAscentDesign Units1,854Height above base line
FontFamily.GetCellDescentDesign Units434Height below base line
FontFamily.GetLineSpacingDesign Units2,355CellAscent + CellDescent + Leading, normally about 115% of ...

Get Windows Forms Programming in Visual Basic .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.