using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace c5_4 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } bool drag = false; private void pictureBox1_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { drag = true; } } private void pictureBox1_MouseMove(object sender, MouseEventArgs e) { if (drag == true) { pictureBox1.Location = new Point(pictureBox1.Location.X+ e.X-pictureBox1.Width/2, pictureBox1.Location.Y + e.Y-pictureBox1.Height/2); } } private void pictureBox1_MouseUp(object sender, MouseEventArgs e) { drag = false; } } }