Windows Develop Bookmark and Share   
 index > Windows Forms Designer > Drawing rectangles on a picture box
 

Drawing rectangles on a picture box

hello,

How can i draw rectangles in a picture wich has an image???

I want to draw rectangles when i clickon the pictureBox

i know i have to use : e.Graphics.FillRectangle(Brushes.White, New Rectangle(X, Y, 10, 10))

but how?

Thank's

djzar2004  Thursday, July 12, 2007 9:40 AM
Be careful using the 'CreateGraphics' in that manner - if you minimise the window and maximise it - the rectangles will disappear? Check out this article for a cleaner approach -> http://www.bobpowell.net/picturebox.htm
Drydo  Thursday, July 12, 2007 1:09 PM

sorry.....m i've found the solution

-*----------------------------------------------------

Private Sub pbMapa_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbMapa.MouseDown

X = e.X

Y = e.Y

End Sub

Private Sub pbMapa_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pbMapa.MouseUp

Dim g As Graphics = pbMapa.CreateGraphics()

g.FillRectangle(Brushes.White, New Rectangle(X, Y, 10, 10))

End Sub

djzar2004  Thursday, July 12, 2007 9:48 AM
Be careful using the 'CreateGraphics' in that manner - if you minimise the window and maximise it - the rectangles will disappear? Check out this article for a cleaner approach -> http://www.bobpowell.net/picturebox.htm
Drydo  Thursday, July 12, 2007 1:09 PM

yea! it's ok

Thank you

djzar2004  Friday, July 20, 2007 11:51 AM

You can use google to search for other answers

Custom Search

More Threads

• Access events of an object from another class which declared on a form
• How to include System.Winforms namespace?
• Query regarding restricting modification of properties....
• Switching form
• Designer problem when extending components in the same project
• Designer problem. Possibly a bug. VS2008
• Datagrid sorting
• Scrolling in Integration.Elementhost
• Help on the Menu Dynamic
• Designer form