c#结合DevExpress控件制作计时器

DevExpress控件

GaugeControl

1.从工具箱中查找定时任务timer


2.从工具箱中查找GaugeControl,选择合适的界面




3.控件界面效果如下

利用工具箱中的GaugeControl控件制作计时器显示界面.
首先要添加一个定时任务:timer,给timer一个timer1_Tick事件

主要代码如下:



    public int currentCouont=0;    privte void timer1_Tick(object sender,EventArgs e){        //设定时间间隔(毫秒为单位)
        System.Timers.Timer timer = new System.Timers.Timer(1000);
        //设置执行一次(false)还是一直执行(true)
        timer.AutoReset = true;
        //设置是否执行System.Timers.Timer.Elapsed事件
        timer.Enabled = true;
        currentCount += 1;
    }
    string second = (currentCount % 60)+"";
    string minute = (currentCount / 60 % 60)+"";
    string hour = (currentCount / 3600)+"";
    if (int.Parse(second) < 10)
    {
        second = "0" + second;
    }
    else {

    }
    if (int.Parse(minute) < 10)
    {
        minute = "0" + minute;
    }
    if (int.Parse(hour) < 10)
    {
        hour = "0" + hour;
    }

    digitalGauge1.Text = hour + ":" + minute + ":" + second;
}
更多博客内容详见我的博客 Wang's Blog

猜你喜欢

转载自blog.csdn.net/abcwanglinyong/article/details/79924109