Polygons

In addition to drawing text, lines, and rectangles, you can also draw polygons that contain any number of sides. The way you would go about doing this is to first create an array of points that represent the vertices of the polygon. This array of points then is passed to the DrawPolygon method on the Graphics object. The Graphics object takes care of drawing the lines from each point to the next and also from the last point back to the first (to create a closed shape).

Here is a simple example that shows how this is done:

 Imports System.Windows.Forms Imports System.Drawing.Drawing2D Imports System.Drawing Public Class Form1 Inherits System.Windows.Forms.Form ...

Get Visual Basic® .NET by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.