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
 
 
 
 
 
TitleDraw a filled polygon in VB .NET
DescriptionThis example shows how to draw a filled polygon in Visual Basic .NET.
Keywordspolygon, fill, filled polygon, VB.NET
CategoriesGraphics, VB.NET
 
To fill the polygon, the program creates a brush that defines the desired fill (a diagonal brick hatch pattern in this case). It then uses the Graphics object's FillPolygon method to fill the polygon.

To outline the polygon, the program makes a pen to define the line style and calls the Graphics object's DrawPolygon method.

 
Private Const MAX_POINT As Integer = 9
Private m_Points(MAX_POINT) As Point

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    Dim the_brush As New _
        System.Drawing.Drawing2D.HatchBrush( _
        Drawing2D.HatchStyle.DiagonalBrick, Color.Red, _
            Color.Orange)
    e.Graphics.FillPolygon(the_brush, m_Points)
    the_brush.Dispose()

    Dim the_pen As New Pen(Color.Blue, 5)
    e.Graphics.DrawPolygon(the_pen, m_Points)
    the_pen.Dispose()
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated