Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDisplay samples of the SystemFonts in Visual Basic .NET
DescriptionThis example shows how to Display samples of the SystemFonts in Visual Basic .NET.
KeywordsSystemFonts, system fonts, font, VB.NET
CategoriesGraphics, Software Engineering, Miscellany, Windows
 
The SystemFonts enumeration lists standard fonts used by the system. The following code calls subroutine DrawSample for each of the fonts in the enumeration. DrawSample displays the font's name and then increases the variable y so it draws the next sample farther down.
 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles Me.Paint
    Dim y As Integer = 0
    DrawSample(e.Graphics, y, "CaptionFont", _
        SystemFonts.CaptionFont)
    DrawSample(e.Graphics, y, "DefaultFont", _
        SystemFonts.DefaultFont)
    DrawSample(e.Graphics, y, "DialogFont", _
        SystemFonts.DialogFont)
    DrawSample(e.Graphics, y, "IconTitleFont", _
        SystemFonts.IconTitleFont)
    DrawSample(e.Graphics, y, "MenuFont", _
        SystemFonts.MenuFont)
    DrawSample(e.Graphics, y, "MessageBoxFont", _
        SystemFonts.MessageBoxFont)
    DrawSample(e.Graphics, y, "SmallCaptionFont", _
        SystemFonts.SmallCaptionFont)
    DrawSample(e.Graphics, y, "StatusFont", _
        SystemFonts.StatusFont)
End Sub

Private Sub DrawSample(ByVal gr As Graphics, ByRef y As _
    Integer, ByVal font_name As String, ByVal sample_font _
    As Font)
    gr.DrawString(font_name, sample_font, Brushes.Black, _
        10, y)
    y += CInt(gr.MeasureString(font_name, _
        sample_font).Height * 1.1)
End Sub
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated