3-3.cs

来自「java基础方面的一些实例代码」· CS 代码 · 共 42 行

CS
42
字号
//程序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 + =
减小字号Ctrl + -
显示快捷键?