Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing a triangle 1

Status
Not open for further replies.

BasicBoy

Programmer
Feb 22, 2008
156
ZA
In VB6 I used to draw a triangle with the polygon API. What is the method in VB.NET ?

Thanks
 
Here's an example. Add this to a blank to a blank form:

Code:
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        e.Graphics.DrawLine(Pens.Black, 50, 25, 25, 75)
        e.Graphics.DrawLine(Pens.Black, 25, 75, 75, 75)
        e.Graphics.DrawLine(Pens.Black, 75, 75, 50, 25)
    End Sub
 
Sorry - I did not put the question fully. The triangle has to be filled with a colour.
 
Code:
   Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim gp As New Drawing2D.GraphicsPath
        gp.AddLine(50, 25, 25, 75)
        gp.AddLine(25, 75, 75, 75)
        gp.AddLine(75, 75, 50, 25)
        e.Graphics.FillPath(Brushes.Red, gp)
    End Sub

This is for illustration purpooses only--obviously, don't declare a new GraphicsPath on each Paint event.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top