怎么在WIN FORM中拖曳一个按钮使其实现移动? 不大可能实现吧,你如果用down的事件来做,那你始终会有up起来的时候,那么就会激活按钮的事件了,那就是拖动一次,就运行一次 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 当然可以了,down的时候你把按钮的位置设成鼠标的位置不就行了。 利用鼠标跟随吧,在按钮的onMouse_Down事件中,动态改变按钮的location private Point mousePos;private void Btn1_MouseDown(object sender,System.Windows.Forms.MouseEventArgs e){ this.canMove =true; this.mousePos =new Point(e.X,e.Y);}private void Btn1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e){ if (this.canMove) { Btn1.Location =new Point(Btn1.Location.X-mousePos.X+e.X,Btn1.Location.Y -mousePos.Y+e.Y); }}private void Btn1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e){ this.canMove =false;} 在form里面好处理,如果要把这个按纽封装起来就要麻烦一点了 listBox1和listView1 c#基础算法,两数相除的实例应用,考考你的C#算法功底 winform程序关于滚动条移动,画面显示的问题 RichTextBox 如何设置行高? 如何用C#拷贝word中的图片到另一个word文档中 winform中textbox输入字符问题 急,有关自定义控件的问题 请版主和高手兄弟介绍一下commerce server,随时在线等待! C#删除文件的问题 有没有不能添加null的IList? 走!去看看! 请问怎样用tcpclient分段收取较大的数据包
private void Btn1_MouseDown(object sender,System.Windows.Forms.MouseEventArgs e)
{
this.canMove =true;
this.mousePos =new Point(e.X,e.Y);
}private void Btn1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (this.canMove)
{
Btn1.Location =new Point(Btn1.Location.X-mousePos.X+e.X,Btn1.Location.Y -mousePos.Y+e.Y);
}
}private void Btn1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
this.canMove =false;
}