Move PictureBox in C#


Try this piece of code.


int x;
int y;

// Storing begin point  (by the left  click)
void pictureBox_MouseDown(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
x = e.X;
y = e.Y;
} }

// Moving the picture
void pictureBox_MouseMove(object sender, MouseEventArgs e) {
if (e.Button == MouseButtons.Left) {
pictureBox1.Left += (e.X - x);
pictureBox1.Top += (e.Y - y);
} }
Related Posts Plugin for WordPress, Blogger...