I am working on simple winform application where I would like to make a picture (box) movable within the main form. However I would like to ensure that the picture cant be moved across the borders. The main form itself should stay resizable. 

The image itself has a resolution of 200x200. I have set the border style of the parent picture box to 'FixedSingle' which results in total picture box control dimensions of 202x202. 

However I am still able to move the picture box slightly "out" of the winform. What am I doing wrong here? 

[![enter image description here](https://i.stack.imgur.com/ueSLZ.png)](https://i.stack.imgur.com/ueSLZ.png)

```
private Point _MouseDownLocation;
private Size _FormSize; 

private void Form1_Load(object sender, EventArgs e) => this._FormSize = Size;

private void Form1_Resize(object sender, EventArgs e) => this._FormSize = ((Form)sender).Size;

private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
    if (e.Button == System.Windows.Forms.MouseButtons.Left)
        _MouseDownLocation = e.Location;    
}

private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
    if (e.Button == System.Windows.Forms.MouseButtons.Left)
    {
        int newX = e.X + pictureBox1.Left - _MouseDownLocation.X;
        int newY = e.Y + pictureBox1.Top - _MouseDownLocation.Y;

        int rightBoundary = _FormSize.Width - pictureBox1.Width;
        int bottomBoundary = _FormSize.Height - pictureBox1.Height - statusStrip1.Height; 

        if (newX <= rightBoundary && newX >= 0 && newY <= bottomBoundary && newY >= 0)
            pictureBox1.Location = new Point(newX, newY);                     
    }
}

```