📄 3-3.cs
字号:
//程序3-3
using System;
using System.Drawing;
using System.Windows.Forms;
public class PresentTimeForm : System.Windows.Forms.Form
{
private System.ComponentModel.IContainer components;
DateTime dTime;
public PresentTimeForm()
{ // InitializeComponent(); // 窗口位置用下一个语句定义了,因此不用调用此函数
this.ClientSize = new System.Drawing.Size(500, 200);
this.Name = "PresentTimeForm";
this.Text = "What time is it now?";
this.Paint += new System.Windows.Forms.PaintEventHandler(this.PresentTimeForm_Paint);
}
static void Main()
{ Application.Run(new PresentTimeForm());
}
private void PresentTimeForm_Paint (object sender, System.Windows.Forms.PaintEventArgs e)
{ dTime = DateTime.Now;
e.Graphics.DrawString( "现在的时间是 "+dTime.ToString(), new Font("Curior New", 18f ), new SolidBrush( Color.Black), 50f, 100f, null);
}
private void InitializeComponent()
{
//
// PresentTimeForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(336, 406);
this.Name = "PresentTimeForm";
this.Load += new System.EventHandler(this.PresentTimeForm_Load);
}
private void PresentTimeForm_Load(object sender, System.EventArgs e)
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -