Jump to content

getting multiple coordinates by clicking an picturebox

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Tiemer

Tiemer

    Newbie

  • Members
  • Pip
  • 1 posts
Hello,

I'm writing an application which should do the following:

4 mouse clicks in a picture box (and getting the coordinates) (now I'm doing this manually with 8 textboxes)
drawing a path between this 4 points (accomplished)
calculating the configuration of 2D-robot and sending this configuration to an arduino (accomplished)

So, which event should I use?

Thanks, Tiemer

#2
CommittedC0der

CommittedC0der

    Speaks fluent binary

  • Members
  • PipPipPipPipPipPipPipPip
  • 1,565 posts
Your problem is getting mouse coordinates from inside the picture box? On a pictureBox click event just record the values to a variable(s)
int x = mouse.x - pictureBox1.x; // mouse location - pictureBox location = mouse location in pictureBox.
int y = mouse.y -  pictureBox1.y;
or
Point xy = new Point(mouse.x - pictureBox1.x , mouse.y - pictureBox1.y);

Note: the above isnt tested code, so the sytax may be off alil and I hope the math works. :P

Good Luck ~ Committed.
A man can be defined by what he does when no one is looking.
Science is only an educated theory, which we cannot disprove.

#3
Momerath

Momerath

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 243 posts
Use the MouseClick event rather than the Click event and it gives you the relative (to the picturebox) X and Y coordinates.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users