public const int WM_NCLBUTTONDOWN = 0xA1;
public const int HTCAPTION = 0x2;
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern bool ReleaseCapture();
[System.Runtime.InteropServices.DllImport("User32.dll")]
public static extern int SendMessage(IntPtr hWnd, int Msg, int wParam, int lParam);
private void panel1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ReleaseCapture();
SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0);
}
}
به کد بالا دقت کنید .
کافیه از خاصیت MouseDown ابزار مورد نظرتون استفاده کنید ، من در دستور بالا از ابزار Panel1 استفاده کردم