formtimer.cs

来自「csharp课本的源代码」· CS 代码 · 共 30 行

CS
30
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace TimerExample
{
    public partial class FormTimer : Form
    {
        public FormTimer()
        {
            InitializeComponent();
        }

        private void timerMy_Tick(object sender, EventArgs e)
        {
            labelDisplay.Text = DateTime.Now.ToLongTimeString();
        }

        private void buttonOK_Click(object sender, EventArgs e)
        {
            timerMy.Enabled = !timerMy.Enabled;
            buttonOK.Text = timerMy.Enabled ? "停止" : "开始";

        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?