C# Panel移动

Point pt;
        private void panel1_MouseDown(object sender, MouseEventArgs e)
        {
            pt = Cursor.Position;
        }

        private void panel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                int px = Cursor.Position.X - pt.X;
                int py = Cursor.Position.Y - pt.Y;
                panel1.Location = new Point(panel1.Location.X + px, panel1.Location.Y + py);

                pt = Cursor.Position;
            }
        }
展开阅读全文

没有更多推荐了,返回首页