日期:2014-05-18 浏览次数:20661 次
private Point lastLocation; private Point lastMsPoint; private Size lastSize; private void label1_MouseDown(object sender, MouseEventArgs e) { this.lastLocation = this.label1.Location; this.lastSize = this.label1.Size; this.lastMsPoint = Control.MousePosition; } private void label1_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { Point mp = Control.MousePosition; if ((ModifierKeys & Keys.Control) == Keys.Control) { this.label1.Size = new Size(this.lastSize.Width + mp.X - this.lastMsPoint.X, this.lastSize.Height + mp.Y - this.lastMsPoint.Y); } else { this.label1.Location = new Point(this.lastLocation.X + mp.X - this.lastMsPoint.X, this.lastLocation.Y + mp.Y - this.lastMsPoint.Y); } } }