问题描述
嗨伙计....我正在练习C#编码...就像在练习..我刚刚创建了一个应用程序...它显示HH:MM:SS AM / PM ..它工作得很好,所有我想做的是..
在特定时间它应该显示一个消息框显示消息...
例如,如果时间是01:00:00 PM ..它应该显示一个消息框,上面有一条消息=午餐时间
所以我写了一个代码......它显示了一条消息,唯一的问题是sooooo很多消息即将发布...近50条消息正在推迟....你们可以帮助我吗?
我写的代码是
hi guys.... i am practicing C# coding... as in practicing.. i just created an application for time... it displays HH:MM:SS AM/PM.. it is working nice and all i want to do is..
at particular time it should display a messagebox showing a message...
for example if time is 01:00:00 PM.. it should display a messagebox with a message = "time to lunch"
so i written a code... it showing a message and the only problem is sooooo many messages are coming... nearly 50 messages are dislaying at time.... can you guys help me in this,,
the code i written is
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString("HH:mm:ss");
if(label1.Text==DateTime.Now.ToString("11:55:00"))
{
MessageBox.Show("time to Lunch");
}
请修改代码来控制消息框..
please modify the code to control the messagebox..
推荐答案
private void timer1_Tick(object sender, EventArgs e)
{
label1.Text = DateTime.Now.ToString("HH:mm");
if (label1.Text == DateTime.Now.ToString("12:16"))
{
MessageBox.Show("time to Lunch");
}
}
private void Form1_Load(object sender, EventArgs e)
{
//Set to 1 second.
timer1.Interval = 1000;
}
这篇关于这么多消息框正在显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!