Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Drawing a Triangle in VB 2005 Express Edition
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
DifinityRJ




PostPosted: 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.
Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: 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.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: