我曾经做过这个,用的是控件的location属性,后来也用过left,right属性。移动是可以,不过会出现两个控件,那时因为没时间也没找出问题所在。你可以试试
解决方案 »
- 请教!
- 关于Property 高手帮帮忙啊!
- 如何根据一个日期得到这个日期所在的春节是哪一天
- 请教如何将数据从文本中提取出来
- ArrayList排序后,用什么函数进行快速搜索?(比如二分查找) 尤其是 ArrayList中的元素是自定义类或者结构时
- 菜鸟:请教大家帮忙,想要个一定时器的代码!
- 用C#开发的软件出现runtime error R6034错误
- 分次写入数据库某一字段
- 求助 DataGrid的问题
- 如何通过ip地址和文件夹绝对地址访问该电脑的该文件夹内内容
- 控制台程序中,static void Main(string[] args) 具体什么意思,能否解释一下,谢谢!
- MsComm串口控件使用问题,做过串口开发的来指教
protected override void WndProc(ref Message m)
{
if (m.Msg == WM_NCHITTEST)
{
m.Result = (IntPtr)HTCAPTION;//移动窗体,但双击可以最大化窗体或还原。
}
}
http://community.csdn.net/Expert/topic/3563/3563219.xml?temp=.4888574
Point t;
private void panel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button==MouseButtons.Left )
{
this.label3.Location=new Point(this.label3.Left + e.X - t.X, this.label3.Top + e.Y - t.Y);
}
}private void panel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
t = new Point(e.X, e.Y);
}
private void panel_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button==MouseButtons.Left )
{
this.panel.Location=new Point(this.panel.Left + e.X - t.X, this.panel.Top + e.Y - t.Y);
}
}private void panel_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
t = new Point(e.X, e.Y);
}
private bool IsMDown = false;
private void pictureBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
IsMDown = true;
Point point = new Point();
point.X = e.X;
point.Y = e.Y;
Oldpoint = point;
} private void pictureBox1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(IsMDown)
{
Point point = new Point();
point = this.DesktopLocation;
this.pictureBox1.Visible=false;
this.pictureBox1.Top = e.Y-point.Y;
this.pictureBox1.Left = e.X-point.X;
this.pictureBox1.Visible=true;
}
} private void pictureBox1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
IsMDown = false;
}