📄 form1.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace Timer_Example
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class fclsTimerExample : System.Windows.Forms.Form
{
private System.Windows.Forms.Timer tmrClock;
private System.Windows.Forms.Label lblClock;
private System.ComponentModel.IContainer components;
public fclsTimerExample()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.tmrClock = new System.Windows.Forms.Timer(this.components);
this.lblClock = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// tmrClock
//
this.tmrClock.Enabled = true;
this.tmrClock.Interval = 1000;
this.tmrClock.Tick += new System.EventHandler(this.tmrClock_Tick);
//
// lblClock
//
this.lblClock.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.lblClock.Location = new System.Drawing.Point(96, 120);
this.lblClock.Name = "lblClock";
this.lblClock.TabIndex = 0;
this.lblClock.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// fclsTimerExample
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.lblClock});
this.Name = "fclsTimerExample";
this.Text = "Timer Example";
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new fclsTimerExample());
}
private void tmrClock_Tick(object sender, System.EventArgs e)
{
DateTime dtCurrentTime = DateTime.Now;
lblClock.Text = dtCurrentTime.ToLongTimeString();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -