View Single Post
  #2 (permalink)  
Old October 23rd, 2013, 09:20 AM
Rod Stephens's Avatar
Rod Stephens Rod Stephens is offline
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts

Hi Wendel,

You can do either of the following (but not both). (I think the second approach is easier.)

1. Use this code to attach the Form1_ Paint method as an event handler to handle the Paint event.

this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_ Paint);
You can place this code in the form's Load event handler. (Double click the form to open it.)

Now fill in the Paint event handler's code.

2. In the form designer, click on the form. Then in the Properties window, click the Events button (it looks like a lightning bolt) to see a list of the form's events.

In the Properties window, now that it is displaying the form's events, double-click on the Paint event handler. That will create an empty event handler where you can put your draw and fill statements.

This also attaches the event handler to the form so you don't need the "Paint +=" statement used by method 1.

I hope that helps.

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)