A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© mzh901024 中级黑马   /  2013-7-18 12:05  /  1416 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

分享给大家主要用到的控件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的事件和频率设置

评分

参与人数 1技术分 +1 收起 理由
zhangcheng5468 + 1 赞一个!

查看全部评分

1 个回复

倒序浏览
值得学习ing!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马