Reputation: 313
Say I had a control like a Picture Box on my Windows Form and I wanted the user to be able to drag it around the panel like a canvas freely to any position they want. What would be the best way to do this?
Afterwards, I want to be able to retrieve the location of the image on the panel. Obviously I'd need the MouseDown event, and my first idea would be to set the location of the control equal to the cursors location, but this glitchy and not smooth.
Upvotes: 0
Views: 370
Reputation: 154
This post might help as well HERE... and to display the output, simply add a label or textbox and display the coordinates- something like:
textbox1.Text = pictureBox1.Location.ToString();
or take the coordinates by:
pictureBox.Location
(which is a point) -or-
pictureBox.Location.X // pictureBox.Location.Y
(which are integers)
Upvotes: 1