C#中关于Timer 控件的问题
我先做一个主窗体,然后由一个button控件(button开始的text为Stop),labell控件,timer控件,现在我想单机button控件开始计时,再单击一下,...
我先做一个主窗体,然后由一个button控件(button开始的text为Stop),labell控件,timer控件,现在我想单机button控件开始计时,再单击一下,停止计时,但运行之后,我还没有单机,就开始计时了(此时按钮为Stop),当我单击后(变成Start),他又不停止,咱单机就不行了,我也不知道问题出在哪儿,请高手赐教,财富值完了,下次补给你们,谢谢了
我的代码如下
void MainFormLoad(object sender, EventArgs e)
{
this.timer1.Enabled=true;
this.timer1.Interval=1000;
}
void Timer1Tick(object sender, EventArgs e)
{
this.label1.Text=DateTime.Now.ToString();
}
void Button1Click(object sender, EventArgs e)
{
if(this.button1.Text=="Stop")
{
this.button1.Text="Start";
this.button1.Enabled=false;
}
else
{
this.button1.Text="Stop";
this.button1.Enabled=true;
}
} 展开
我的代码如下
void MainFormLoad(object sender, EventArgs e)
{
this.timer1.Enabled=true;
this.timer1.Interval=1000;
}
void Timer1Tick(object sender, EventArgs e)
{
this.label1.Text=DateTime.Now.ToString();
}
void Button1Click(object sender, EventArgs e)
{
if(this.button1.Text=="Stop")
{
this.button1.Text="Start";
this.button1.Enabled=false;
}
else
{
this.button1.Text="Stop";
this.button1.Enabled=true;
}
} 展开
2个回答
展开全部
void MainFormLoad(object sender, EventArgs e)
{
this.timer1.Enabled=true;
this.timer1.Interval=1000;
}
void Timer1Tick(object sender, EventArgs e)
{
this.label1.Text=DateTime.Now.ToString();
}
void Button1Click(object sender, EventArgs e)
{
if(this.button1.Text=="Stop")
{
this.button1.Text="Start";
this.timer1.Enabled=false;
}
else
{
this.button1.Text="Stop";
this.timer1.Enabled=true;
}
}
{
this.timer1.Enabled=true;
this.timer1.Interval=1000;
}
void Timer1Tick(object sender, EventArgs e)
{
this.label1.Text=DateTime.Now.ToString();
}
void Button1Click(object sender, EventArgs e)
{
if(this.button1.Text=="Stop")
{
this.button1.Text="Start";
this.timer1.Enabled=false;
}
else
{
this.button1.Text="Stop";
this.timer1.Enabled=true;
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
private void Form1_Load(object sender, EventArgs e)
{
timer1.Enabled = true;
timer1.Interval = 1000;
}
private void button1_Click(object sender, EventArgs e)
{
if (timer1.Enabled)
{
button1.Text = "start";
timer1.Enabled = false;
}
else
{
button1.Text = "stop";
timer1.Enabled = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
}
{
timer1.Enabled = true;
timer1.Interval = 1000;
}
private void button1_Click(object sender, EventArgs e)
{
if (timer1.Enabled)
{
button1.Text = "start";
timer1.Enabled = false;
}
else
{
button1.Text = "stop";
timer1.Enabled = true;
}
}
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString();
}
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询