Question picture box with crosshair

Zexor

Well-known member
Joined
Nov 28, 2008
Messages
520
Programming Experience
3-5
I am trying to keep a horizontal line and a vertical line in the middle of a picturebox like a crosshair. But everytime the box refresh it will disappear. Where should i put the draw command so that the crosshair is always there above the picture?
 
Draw in the Paint event handler, call Invalidate/Update or Refresh if you need to force a repaint manually.
 
I have tried drawing it in paint but it doesnt seem to work. if i put invalidate or refresh in paint, it will just be looping the paint event forever and making the crosshair freshing in and out really fast.
 
Hi Zexor, never put put Invalidate or Refresh inside the Paint event sub. They are only needed when you want to fire a Paint event in response to some other event, such as MouseMove. Then you would put one or the other in the MouseMove sub. You will need Refresh or Invalidate only if the crosshairs have to move; I think that's what JohnH meant. If your crosshairs are static you don't need them at all.

VicJ
 
Last edited:
Back
Top