Newbie graphic question

G

Guest

I have a simple problem that I just cannot figure out. I have a picturebox on a form that displays an image. I would like a red dot to appear on the picture when the user clicks on a certain location. here is the code that is not working

dim gr as graphic

Private Sub global5_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMov
gr = PictureBox1.CreateGraphic
gr.DrawEllipse(New Pen(Color.Red), e.X, e.Y, 3, 3
End Su

thank
mik
 
E

Ed Kaim [MSFT]

Try this instead:

Private Sub global5_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
gr = Graphics.FromImage(PictureBox1.Image)
gr.DrawEllipse(New Pen(Color.Red), e.X, e.Y, 3, 3)
PictureBox1.Refresh()
End Sub

Mike_Deck said:
I have a simple problem that I just cannot figure out. I have a
picturebox on a form that displays an image. I would like a red dot to
appear on the picture when the user clicks on a certain location. here is
the code that is not working:
dim gr as graphics

Private Sub global5_MouseMove(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove
 
V

V

You must handle MouseDown not MouseMove
-----Original Message-----
I have a simple problem that I just cannot figure out. I
have a picturebox on a form that displays an image. I
would like a red dot to appear on the picture when the
user clicks on a certain location. here is the code that
is not working:
dim gr as graphics

Private Sub global5_MouseMove(ByVal sender As Object,
ByVal e As System.Windows.Forms.MouseEventArgs) Handles
MyBase.MouseMove
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top