c# 每隔一分钟就弹一次对话框怎么写

笨笨狮子 2010-04-01 02:48:29
请问各位哥哥,姐姐,我想写一个小程序,就是一点按钮后,程序就自主动梅隔一分种就弹出一个MessageBox
不能一运行程序就谈这个东西,必须要点了按钮才行,各位能不能帮俺想想,最好有代码,也让俺参考一下,谢谢各位哥哥姐姐了
...全文
214 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
Neil198 2010-04-01
  • 打赏
  • 举报
回复
大哥,我这是手写的伪代码。
timer1.Interval = 60*1000; =无效呢??
timer1.Tick + = new System.EventHandler(this.timer1_Tick);

这两句你要放在load里面,或者从控件里面托出来。。

[Quote=引用 7 楼 adslhack 的回复:]

3 楼你这个代码测试了吗?我这里怎么提于
timer1.Interval = 60*1000; =无效呢??
timer1.Tick + = new System.EventHandler(this.timer1_Tick); // 提示+=无效
[/Quote]
rosejing 2010-04-01
  • 打赏
  • 举报
回复
楼主解决了吗
kofpanyifei 2010-04-01
  • 打赏
  • 举报
回复

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = true;
}

private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.Show("aaa");
}

private void button2_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
}
}
}

就添加了两个BUTTON和一个Timer
kofpanyifei 2010-04-01
  • 打赏
  • 举报
回复
首先从工具箱中找到一个叫Timer的控件,拖到窗体中,然后点Timer再属性中改Iterval为60000(单位毫秒),然后添加以下代码

private void button1_Click(object sender, EventArgs e)//开始按钮事件
{
timer1.Enabled = true;
}

private void timer1_Tick(object sender, EventArgs e)//这个在Timer控件的事件中,就那么一个事件
{
MessageBox.Show("aaa");
}

private void button2_Click(object sender, EventArgs e)//关闭按钮事件
{
timer1.Enabled = false;
}
笨笨狮子 2010-04-01
  • 打赏
  • 举报
回复
我的为什么老是提于这个呀
笨笨狮子 2010-04-01
  • 打赏
  • 举报
回复
笨笨狮子 2010-04-01
  • 打赏
  • 举报
回复
哥哥,姐姐们,都别玩我了,我急用呀,就是一点按钮后,程序就自主动梅隔一分种就弹出一个对话框来,如果不关对话框一直弹都行。我在线等呀
Code従業員 2010-04-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 adslhack 的回复:]
3 楼你这个代码测试了吗?我这里怎么提于
timer1.Interval = 60*1000; =无效呢??
timer1.Tick + = new System.EventHandler(this.timer1_Tick); // 提示+=无效
[/Quote]

你要先到左边的工具栏了吧拖个Timer(就是那个蓝色的怀表)放到窗体上。
herty 2010-04-01
  • 打赏
  • 举报
回复
[Quote=引用 7 楼 adslhack 的回复:]
3 楼你这个代码测试了吗?我这里怎么提于
timer1.Interval = 60*1000; =无效呢??
timer1.Tick + = new System.EventHandler(this.timer1_Tick); // 提示+=无效
[/Quote]
你们俩用的控件不一样.
Code従業員 2010-04-01
  • 打赏
  • 举报
回复
while(true)
{
thread.sleep(60000);
MessageBox.show("按钮点击事件中");
}
笨笨狮子 2010-04-01
  • 打赏
  • 举报
回复
3 楼你这个代码测试了吗?我这里怎么提于
timer1.Interval = 60*1000; =无效呢??
timer1.Tick + = new System.EventHandler(this.timer1_Tick); // 提示+=无效
Alden 2010-04-01
  • 打赏
  • 举报
回复
如果上一个对话框没有关闭,下一个继续弹出或者不弹,你可能需要异步弹出
Jelly_tracy 2010-04-01
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 neil198 的回复:]
C# code

Timer timer1 = new Timer();
timer1.Interval = 60*1000;
timer1.Tick + = new System.EventHandler(this.timer1_Tick);
private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.……
[/Quote]


楼主,试试
deyter 2010-04-01
  • 打赏
  • 举报
回复

private void Form1_Load(object sender, EventArgs e)
{
timer1.Interval = 60000;
timer1.Start();
}

private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.Show("1 min");
}
Neil198 2010-04-01
  • 打赏
  • 举报
回复

Timer timer1 = new Timer();
timer1.Interval = 60*1000;
timer1.Tick + = new System.EventHandler(this.timer1_Tick);
private void timer1_Tick(object sender, EventArgs e)
{
MessageBox.Show("aaaaa");
}
Button btnStar = new Button();
btnStar.Text = "开始";
btnStar.Click += new System.EventHandler(btnStar_Click);
private void btnStar_Click(object sender, EventArgs e)
{
timer1.Star();
}
笨笨狮子 2010-04-01
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 juedaihuaihuai 的回复:]
timer控件
[/Quote]
timer 控件怎么使用呀,我怎么老是做不到呀
绝代坏坏 2010-04-01
  • 打赏
  • 举报
回复
timer控件

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧