您的位置:首页 > 编程语言 > C#

C#鼠标按住标题移动时移动窗体

2012-08-25 10:52 330 查看
//鼠标在标题处按下时记录鼠标位置

private void label_caption_MouseDown(object sender, MouseEventArgs e)

{

mousePoint = new Point(e.X, e.Y);

}

//鼠标按住标题移动时移动窗体

private void label_caption_MouseMove(object sender, MouseEventArgs e)

{

if (e.Button == MouseButtons.Left)

{

this.SetBounds(this.Location.X + e.X - mousePoint.X, this.Location.Y + e.Y - mousePoint.Y, this.Width, this.Height);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: