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 brushes in Visual Basic .NET
DescriptionThis example shows how to display predefined system brushes in Visual Basic .NET.
Keywordsbrush, system brush, SystemBrushes, drawing, graphics, VB.NET
CategoriesGraphics, VB.NET
 
The form's Paint event handler calls subroutine DrawBrushSample for each defined SystemBrushes value. DrawBrushSample fills a rectangle using a brush and then displays the brush's name.
 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    Dim y As Integer = 10
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ActiveBorder, "ActiveBorder")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ActiveCaption, "ActiveCaption")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ActiveCaptionText, _
        "ActiveCaptionText")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.AppWorkspace, "AppWorkspace")
    DrawBrushSample(e.Graphics, y, SystemBrushes.Control, _
        "Control")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ControlDark, "ControlDark")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ControlDarkDark, "ControlDarkDark")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ControlLight, "ControlLight")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ControlLightLight, _
        "ControlLightLight")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.ControlText, "ControlText")
    DrawBrushSample(e.Graphics, y, SystemBrushes.Desktop, _
        "Desktop")
    DrawBrushSample(e.Graphics, y, SystemBrushes.Highlight, _
        "Highlight")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.HighlightText, "HighlightText")
    DrawBrushSample(e.Graphics, y, SystemBrushes.HotTrack, _
        "HotTrack")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.InactiveBorder, "InactiveBorder")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.InactiveCaption, "InactiveCaption")
    DrawBrushSample(e.Graphics, y, SystemBrushes.Info, _
        "Info")
    DrawBrushSample(e.Graphics, y, SystemBrushes.Menu, _
        "Menu")
    DrawBrushSample(e.Graphics, y, SystemBrushes.ScrollBar, _
        "ScrollBar")
    DrawBrushSample(e.Graphics, y, SystemBrushes.Window, _
        "Window")
    DrawBrushSample(e.Graphics, y, _
        SystemBrushes.WindowText, "WindowText")
End Sub

Private Sub DrawBrushSample(ByVal gr As Graphics, ByRef y _
    As Integer, ByVal br As Brush, ByVal br_name As String)
    gr.FillRectangle(br, 10, y, 90, 10)
    gr.DrawRectangle(Pens.Black, 10, y, 90, 10)
    gr.DrawString(br_name, Me.Font, Brushes.Black, 110, y)
    y += 15
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated