110,533
社区成员
发帖
与我相关
我的任务
分享
public MainForm()
{
InitializeComponent();
this.btn1.MouseDown += new MouseEventHandler(btn_MouseDown );
this.btn2.MouseDown += new MouseEventHandler(btn_MouseDown );
}
private void btn_MouseDown(object sender, MouseEventArgs e)
{
//这里写你要的判断,只要鼠标没事释放 就会不停执行此事件
}
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
this.MouseMove += new MouseEventHandler(Control_MouseMove);
}
void Control_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left )
{
Control c = ((Form)sender).GetChildAtPoint(e.Location);
if ((Button)c==button1)
textBox1.Text = "123";
}
}
}
}