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 polygons in VB.NET
DescriptionThis example shows how to draw polygons VB.NET. This example demonstrates the Graphics object's DrawPolygon method.
Keywordspolygon, DrawPolygon, VB.NET
CategoriesGraphics, VB.NET
 
This example builds an array of Point objects and passes it to the Graphics object's DrawPolygon method.
 
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As _
    System.Windows.Forms.PaintEventArgs) Handles _
    MyBase.Paint
    Dim pts() As Point = { _
        New Point(10, 10), _
        New Point(200, 100), _
        New Point(300, 50), _
        New Point(350, 120), _
        New Point(240, 260), _
        New Point(120, 150), _
        New Point(50, 310), _
        New Point(70, 190) _
    }
    e.Graphics.SmoothingMode = _
        Drawing2D.SmoothingMode.AntiAlias
    e.Graphics.DrawPolygon(Pens.Black, pts)
End Sub
 
Note that the Graphics object also has a corresponding FillPolygon method that takes exactly the same arguments as DrawPolygon except its uses a Brush instead of a Pen.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated