public partial class Form1 : Form
{
private bool isMouseDown = false;
private Point oldMouse;
public Form1()
{
InitializeComponent();
}
private void Form1_MouseMove(object sender, MouseEventArgs e)
{
if (isMouseDown)
{
this.Top = this.Top + e.Y - oldMouse.Y;
this.Left = this.Left + e.X - oldMouse.X;
}
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
oldMouse.X = e.X;
oldMouse.Y = e.Y;
isMouseDown = true;
}
}
private void Form1_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
isMouseDown = false;
}
}
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
}
27
2012
03
BorderStyle设成none的窗体的移动
发布:郑德才博客 | 分类:学习之路 | 评论:0 | 浏览:
相关文章:
jQuery实现元素的上下移动示例代码 (2014-8-5 9:46:4)
input类型为file的浏览窗体中只显示指定文件类型 (2013-4-11 20:55:20)
C#一窗体的事件控制另一窗体的属性 (2012-4-4 10:57:22)
C# 窗体位于中间 (2012-4-3 11:20:49)
C#窗体及控件的快捷键 (2012-4-1 13:49:42)
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。