Imports System.Drawing Imports System.Drawing.Drawing2D Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load End Sub Private Sub Form1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint ' Create pen. Dim blackPen As New Pen(Color.Black, 3) ' Create triangle. Dim point1 As New Point(15, 65) Dim point2 As New Point(100, 150) Dim point3 As New Point(195, 65) Dim myGraphicsPath As New GraphicsPath myGraphicsPath.AddLine(point1.X, point1.Y, point2.X, point2.Y) myGraphicsPath.AddLine(point1.X, point1.Y, point3.X, point3.Y) myGraphicsPath.AddLine(point3.X, point3.Y, point2.X, point2.Y) Dim myRegion As New Region(myGraphicsPath) Dim myBrush As New SolidBrush(Color.Red) e.Graphics.FillRegion(myBrush, myRegion) ' Create rectangle. Dim rect As New Rectangle(5, 5, 200, 200) ' Draw rectangle to screen. e.Graphics.DrawRectangle(blackPen, rect) End Sub End Class
Originally Posted on December 20, 2013
Last Updated on October 26, 2015
Last Updated on October 26, 2015
All information on this site is shared with the intention to help. Before any source code or program is ran on a production (non-development) system it is suggested you test it and fully understand what it is doing not just what it appears it is doing. I accept no responsibility for any damage you may do with this code.