79167617

Date: 2024-11-07 18:14:43
Score: 1
Natty:
Report link

I just cast the sender to a pictureBox and use the MouseEventArgs, note that the position of the mouse become the top left corner position of the pictureBox.

    private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
    {
        if (e.Button == MouseButtons.Left)
        {
            var pictureBox = (PictureBox)sender;
            pictureBox.Location = new Point(pictureBox.Left + e.X, pictureBox.Top + e.Y);
        }
    }
Reasons:
  • Has code block (-0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Pasa