This question has already been answered:

How to make so that the movement of the form was carried out not only for the upper limit, but for any part of this form?

Reported as a duplicate by PashaPash member c # 28 Dec '16 at 21:53 .

A similar question was asked earlier and an answer has already been received. If the answers provided are not exhaustive, please ask a new question .

  • 2
    there are several solutions, WinAPI is used - RusArt
  • ru.stackoverflow.com/a/527892/198316 this variant easily adapts to the form, the form is also a control. There is also a link to another solution using WinAPI. Depends on the final goal - rdorn

2 answers 2

It is possible through the event handler, when you hold the mouse on the form and move the mouse, change the property of the form position, that is, add the mouse offset coordinates to the form coordinates, this is if the WinAPI option does not work for you

  • Now I will try this option and write down how it looks visually. - Alexander Puzanov

Thank you all. Following the link Ruslana Artamonov chose this varinat. Everything works out beautifully:

  public const int WM_NCLBUTTONDOWN = 0xA1; public const int HTCAPTION = 0x2; [DllImport("User32.dll")] public static extern bool ReleaseCapture(); [DllImport("User32.dll")] public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam); void Form_Load(object sender, EventArgs e) { this.MouseDown += new MouseEventHandler(Form_MouseDown); } void Form_MouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ReleaseCapture(); SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0); } } 

Leaving out some details, the form began to look like this. From any place of the form, except for controls, you can drag on the screen. enter image description here