zoukankan      html  css  js  c++  java
  • WPF动态时间(电子表)

    private DispatcherTimer dispatcherTimer;
    
            public MainWindow()
            {
                InitializeComponent();
    
                dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
                // 当间隔时间过去时发生的事件
                dispatcherTimer.Tick += new EventHandler(ShowCurrentTime);
                dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 1);
                dispatcherTimer.Start();
            }
    
            public void ShowCurrentTime(object sender, EventArgs e)
            {
                //获得星期
                //this.tBlockTime.Text = DateTime.Now.ToString("dddd", new System.Globalization.CultureInfo("zh-cn"));
                //this.tBlockTime.Text += "
    ";
    
                //获得年月日
                //this.tBlockTime.Text = DateTime.Now.ToString("yyyy:MM:dd");   //yyyy年MM月dd日
                //this.tBlockTime.Text += "
    ";
    
                //获得时分秒
                this.tBlockTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss dddd");
            }
    <TextBlock Name="tBlockTime" FontSize="40"  Grid.Column="1" HorizontalAlignment="Right" Foreground="Green"/>

    运行效果:

  • 相关阅读:
    tp5 生成数据表
    tp5 事务
    时间
    api json
    php 函数学习
    win7 安装Ubuntu18.04 双系统后无法引导win7
    vite笔记
    tp5 excel导出
    tp5 sql查询
    idea 停止运行程序
  • 原文地址:https://www.cnblogs.com/YYkun/p/7251755.html
Copyright © 2011-2022 走看看