By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,168 Members | 2,511 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,168 IT Pros & Developers. It's quick & easy.

Picturebox coordinates

P: n/a
Dear Group,

I wonder if anyone can help me with a little VB.NET picturebox problem?

I want to let the user click on a map and where they click I want to
draw a circle. I'm using the PictureBox.MouseDown event to capture the
position of the mouse when the button is clicked. That works fine.
However when I draw a circle at that position the circle is drawn
offset by varying amounts depending on the position of the window. How
can I fix this so that the mouseposition is relative to the picturebox

nx = PictureBox1.MousePosition.X
ny = PictureBox1.MousePosition.Y
Dim message As String
message = CStr(nx) + ", " + CStr(ny)
Label2.Text = (message)
Dim graphics As System.Drawing.Graphics = PictureBox1.CreateGraphics()
Dim rectangle As New
System.Drawing.Rectangle(PictureBox1.MousePosition .X,
PictureBox1.MousePosition.Y, 10, 10)
graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle)

Nov 21 '05 #1
Share this Question
Share on Google+
1 Reply

P: n/a
Hi all again,

After doing my head in for an hour I've just fixed this problem with


Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.