[英]Title show while timer is enabled
so I have a problem where I want to make a label pop up when timer is enabled.所以我有一个问题,我想在启用计时器时弹出 label。 I tried writing this but it just doesn't work.
我试着写这个,但它不起作用。 I have set every object property as needed, but still there is some kind of problem.
我已经根据需要设置了每个 object 属性,但仍然存在某种问题。 Can you help me please?
你能帮我吗? Thanks.
谢谢。
private void timer1_Tick(object sender, EventArgs e)
{
if (button3Click == true && FullNameBOX.Text == "")
{
timer1.Start();
while(timer1.Enabled == true)
{
label5.Show();
}
timer1.Stop();
}
else if(timer1.Enabled == false)
{
label5.Hide();
}
else
{
}
timer1_Tick
is only executed once the timer is started and the timer interval is elapsed for the first time and then repeatedly every interval. timer1_Tick
仅在定时器启动且定时器间隔第一次结束后执行,然后在每个间隔重复执行。 So you must start the timer somewhere else.所以你必须在别处启动计时器。 In button
button3_Click
I assume在按钮
button3_Click
我假设
private void button3_Click(object sender, EventArgs e)
{
if (FullNameBOX.Text == "")
{
label5.Show();
timer1.Start();
}
else
{
... process the FullNameBOX.Text
}
}
In the Tick event handler stop the timer and hide the label在 Tick 事件处理程序中停止计时器并隐藏 label
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Stop();
label5.Hide();
}
Also, give better names to your controls.此外,为您的控件提供更好的名称。 It's best to do so before creating the event handlers so that those get better names too.
最好在创建事件处理程序之前这样做,这样它们也可以获得更好的名称。 It is easier to understand
messageLabel
than label5
and SaveButton_Click
than button3_Click
. messageLabel
比label5
更容易理解, SaveButton_Click
比button3_Click
更容易理解。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.