winform 控件中显示实时时间

///1.拖出timer控件和label控件
///2.在timer1_tick中将系统时间赋值给label的text
///3.在form_load中开启控件
using System.Collections.Generic;  
using System.ComponentModel;  
using System.Data;  
using System.Drawing;  
using System.Linq;  
using System.Text;  
using System.Windows.Forms;  
  
namespace myclient  
{  
    public partial class Form1 : Form  
    {  
        public Form1()  
        {  
            InitializeComponent();  
        }  
  
        private void Form1_Load(object sender, EventArgs e)  
        {  
            timer1.Start();  
        }  
          
        private void timer1_Tick(object sender, EventArgs e)  
        {  
            label2.Text = System.DateTime.Now.ToString();  
        }  
    }  
}  
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页