Drawing a Triangle in VB 2005 Express Edition
Author |
Message |
DifinityRJ
![](http://compsci.ca/v3/uploads/user_avatars/1665843594662f4952a669.jpg)
|
Posted: Sat Mar 15, 2008 2:22 pm Post subject: Drawing a Triangle in VB 2005 Express Edition |
|
|
I need to Draw a roof, and I want to Draw a Triangle, but there is no command for it.
The only other command I can think of is Drawpolygon, but I can't figure out how to use it properly, and I also want to fill the roof in with a certain color.
Thanks. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
rdrake
![](http://compsci.ca/v3/uploads/user_avatars/113417932472fc6c9cd916.png)
|
Posted: Sat Mar 15, 2008 4:20 pm Post subject: Re: Drawing a Triangle in VB 2005 Express Edition |
|
|
You need to draw any shapes on the OnPaint() method.
code: | protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
List<Point> points = new List<Point>();
points.add(new Point(myX, myY));
points.add(new Point(mySecondX, mySecondY));
Graphics g = e.Graphics;
g.DrawPolygon(Pens.Black, points.ToArray());
} | The VB.NET code shouldn't be much different, it's essentially C# anyways.
The basic idea is that you must draw shapes on the form during the OnPaint() event, and the proper way to draw items on the form is as above.
Oh yes, and you can create your own Pen object and pass that to g.DrawPolygon() instead if you want different sizes or whatever. |
|
|
|
|
![](images/spacer.gif) |
|
|