Move a form that has no border.

Using the code below , we can design a form with beauitful borders. These forms can also be moved at runtime like the normal form.

1) go to the properties of the form and make the properties-->formBorder-->None
2) drop pictureBox with the desired image, which looks like the title bar.
Name it PtbTitle.
3)one button for minimising form
4)one button to Close the form
5)now write this code:

private bool mouse_is_down = false;
private Point mouse_pos;
  private void PtbTitle_MouseMove(object sender, MouseEventArgs e)
            if (mouse_is_down)
                Point current_pos = Control.MousePosition;
                current_pos.X = current_pos.X - mouse_pos.X; // .Offset(mouseOffset.X, mouseOffset.Y);
                current_pos.Y = current_pos.Y - mouse_pos.Y;
                this.Location = current_pos;

        private void PtbTitle_MouseDown(object sender, MouseEventArgs e)
            mouse_pos.X = e.X;
            mouse_pos.Y = e.Y;
            mouse_is_down = true;

        private void PtbTitle_MouseUp(object sender, MouseEventArgs e)
            mouse_is_down = false;

        private void Minimize_Button_Click(object sender, EventArgs e)
            WindowState = FormWindowState.Minimized;

        private void BtnClose_Click(object sender, EventArgs e)

Now you can move the form at runtime...

By alice johnson   Popularity  (1826 Views)