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
 
 
 
 
 
 
TitleUse stock pens and brushes in VB .NET
Keywordspen, brush, stock, stock pen, stock brush, VB.NET
CategoriesGraphics, VB.NET
 
The program creates a Rectangle to draw later. Then it uses the Graphics object's FillRectangle method to fil the rectangle. It uses the aqua brush provided by the Brushes class. These brushes represent a solid fill using standard colors.

Next the program calls the Graphics object's DrawRectangle method to outline the rectangle. It uses a blue pen provided by the Pens class. These pens are solid and one pixel wide.

 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    Dim rect As New Rectangle(10, 10, _
        Me.ClientSize.Width - 20, _
        Me.ClientSize.Height - 20)

    ' Fill a rectangle with a solid Aqua brush.
    e.Graphics.FillRectangle(Brushes.Aqua(), rect)

    ' Outline the rectangle with 1-pixel line.
    e.Graphics.DrawRectangle(Pens.Blue(), rect)
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated