c# - 闪光次数有限的定时器
问题描述
启动表单时,我需要计时器闪烁 8 次:“按 OK 按钮”并停止闪烁。上网搜索,但没有找到。我试着写了一个循环,但还是不明白怎么写。你能写一个计时器并解释它是如何工作的吗?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WindowsFormsApp7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
timer1.Start();
}
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_MouseMove(object sender, MouseEventArgs e)
{
int w = (int)this.button1.Size.Width;
int h = (int)this.button1.Size.Height;
Random r = new Random();
button1.Left = r.Next(0, this.Size.Width - button1.Width);
button1.Top = r.Next(0, this.Size.Height - button1.Height);
this.button1.Size = new System.Drawing.Size(w - 3, h - 3);
if (button1.Focused)
{
this.Text = "Мимо";
}
else
{
this.Text = "Нажміть на кнопку ОК!!!";
}
}
private int time;
private void timer1_Tick(object sender, EventArgs e)
{
this.Text = time.ToString("click OK"); //timer
}
}
}
解决方案
推荐阅读
- excel - 当文件夹不为空时,电子表格无法导出到 Access 数据库
- firebase - 如何从 firebase 子集合中获取数据?
- javascript - 做出反应。流式 JSON 文件
- gremlin - gremlin 在两个顶点之间添加顶点 - 在单个查询中?
- c# - 使用 DTOList 更新表
- php - 语法错误:第 0 行,第 72 列:错误:预期的字符串结尾,得到 'b6f037'
- vaadin - Vaadin 加载微调器
- javascript - 在 post 请求中发送带有文件的数据
- javascript - Vue js - 将数据传递给 Vue js 组件中的道具
- api - DomainBox REST API 错误 - 提交请求时出错