In C# WinForm, if the border is not displayed, the form cannot be dragged, which can be solved by adding the code below.
1. Import namespace
using System.Runtime.InteropServices;
2. Enter the following code
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage (IntPtr hwnd, int wMsg, int wParam, int lParam);
private void pictureBox2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void pictureBox4_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized ;
}
Write the following code in the form's MouseDown event
private void zcmmForm_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture(); SendMessage(Handle, 0xA1, 0x02, 0);
}
}
The problem that the form cannot be dragged after removing the border