解决方案 »

  1.   

    http://www.cnblogs.com/coolkid/archive/2012/07/14/2591602.html
      

  2.   


    using System.Runtime.InteropServices; 
    //并为控件 添加 MouseDown 事件
     
    // C#鼠标拖动任意控件
     
    // 利用Windows的API函数:SendMessage 和 ReleaseCapture 
    const uint WM_SYSCOMMAND = 0x0112;
    const uint SC_MOVE = 0xF010;
    const uint HTCAPTION = 0x0002;
     
    [DllImport("user32.dll", EntryPoint = "SendMessageA")]
    private static extern int SendMessage(IntPtr hwnd, uint wMsg, uint wParam, uint lParam);
    [DllImport("user32.dll")]
    private static extern int ReleaseCapture();
     
    void ControlMouseDown(object sender, MouseEventArgs e)
    {
        ReleaseCapture();
        SendMessage((sender as Control).Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);
    }