110,534
社区成员
发帖
与我相关
我的任务
分享
//设置一个标志位,标识是否向前结束
private bool IsEnd ;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
this.IsEnd = false;
while(!this.IsEnd)
{
//执行
}
}
private void button1_MouseUp(object sender, MouseEventArgs e)
{
this.IsEnd = true;
}
//设置一个标志位,标识是否向前结束
private bool IsEnd ;
//模拟执行范围
private int range = 10;
private void button1_MouseDown(object sender, MouseEventArgs e)
{
this.IsEnd = false;
int i = 0;
while(!this.IsEnd)
{
i++;//模拟执行
if(i > range) this.IsEnd = true;
}
}
/// <summary>
/// 按下按钮一
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_MouseDown(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
this.timer1.Enabled = true;
}
}
/// <summary>
/// 时间控件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void timer1_Tick(object sender, EventArgs e)
{
//移动名为btnMove的按钮
this.btnMove.Location = new Point(this.btnMove.Location.X + 1, this.btnMove.Location.Y);
}
/// <summary>
/// 释放按钮一
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_MouseUp(object sender, MouseEventArgs e)
{
this.timer1.Enabled = false;
}