分享给大家主要用到的控件Timer的事件和频率设置
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace YaoJiangJi
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
string[] numbers = { "13912345678", "13258966666", "13334567892", "13667429772", "18975641235", "18752414455", "18255546663", "15685241564", "15897456231", "13645899632" };
private void Form1_Load(object sender, EventArgs e)
{
this.timer1.Stop();
}
private void timer1_Tick(object sender, EventArgs e)
{
Random r = new Random();
int index = r.Next(numbers.Length);//产生是随机数
this.lb_Number.Text = numbers[index];
}
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
//MessageBox.Show(e.KeyValue.ToString());//测试键值
if (e.KeyValue == 32)
{
this.timer1.Start();
}
if (e.KeyValue == 13)
{
this.timer1.Stop();
this.lb_Number.Text = this.lb_Number.Text.Substring(0, 3) + "****" + this.lb_Number.Text.Substring(7, 4);
}
}
}
}
分享给大家主要用到的控件Timer的事件和频率设置
|