Drawing graphics on form load?

05-29-2006, 04:53 PM
I have a procedure that allows me to draw an ellipse. I works great when I cause this to happen with the even of clicking a button. But, when I insert the exact same code in the form_load Sub, nothing happens. Is there a reason for this?

Here is what I am trying to do:

dim mypen as new pen = pen(color.red)
dim design1 as graphics = picturebox1.creategraphics
design1.drawellipse(mypen, 10, 10, 10,10)

works fine with a button click, but not on the form load...wierd. It actually goes through the code, but nothing shows up.

05-29-2006, 08:05 PM
The Load event fires before the form is shown (and thus painted). When the form and picturebox are actually shown following the Load event, they are repainted (erasing anything painted earlier). You need to draw either in the picturebox's Paint event or else to a bitmap that the picturebox's Image property is then set to.

EDIT: Oh, and I recommend this FAQ, check out question #1: http://www.bobpowell.net/faqmain.htm

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum