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 predefined system pens in Visual Basic .NET
DescriptionThis example shows how to display predefined system pens in Visual Basic .NET.
Keywordspen, system pen, SystemPens, drawing, graphics, VB.NET
CategoriesGraphics, VB.NET
 
The form's Paint event handler calls subroutine DrawLineSample for each defined SystemPens value. DrawLineSample draws a line using a pen and then displays the pen's name.
 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    e.Graphics.FillRectangle(Brushes.White, 0, 0, 55, _
        Me.ClientSize.Height)

    Dim y As Integer = 10
    DrawLineSample(e.Graphics, y, _
        SystemPens.ActiveCaptionText, "ActiveCaptionText")
    DrawLineSample(e.Graphics, y, SystemPens.Control, _
        "Control")
    DrawLineSample(e.Graphics, y, SystemPens.ControlDark, _
        "ControlDark")
    DrawLineSample(e.Graphics, y, _
        SystemPens.ControlDarkDark, "ControlDarkDark")
    DrawLineSample(e.Graphics, y, SystemPens.ControlLight, _
        "ControlLight")
    DrawLineSample(e.Graphics, y, SystemPens.ControlText, _
        "ControlText")
    DrawLineSample(e.Graphics, y, SystemPens.GrayText, _
        "GrayText")
    DrawLineSample(e.Graphics, y, SystemPens.Highlight, _
        "Highlight")
    DrawLineSample(e.Graphics, y, SystemPens.HighlightText, _
        "HighlightText")
    DrawLineSample(e.Graphics, y, _
        SystemPens.InactiveCaptionText, _
        "InactiveCaptionText")
    DrawLineSample(e.Graphics, y, SystemPens.InfoText, _
        "InfoText")
    DrawLineSample(e.Graphics, y, SystemPens.MenuText, _
        "MenuText")
    DrawLineSample(e.Graphics, y, SystemPens.WindowFrame, _
        "WindowFrame")
    DrawLineSample(e.Graphics, y, SystemPens.WindowText, _
        "WindowText")
End Sub

Private Sub DrawLineSample(ByVal gr As Graphics, ByRef y As _
    Integer, ByVal the_pen As Pen, ByVal pen_name As String)
    gr.DrawLine(the_pen, 10, y, 100, y)
    y -= CInt(0.5 * gr.MeasureString(pen_name, _
        Me.Font).Height)
    gr.DrawString(pen_name, Me.Font, Brushes.Black, 110, y)
    y += CInt(1.6 * gr.MeasureString(pen_name, _
        Me.Font).Height)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated