form1.cs

来自「《c#技术内幕代码》」· CS 代码 · 共 64 行

CS
64
字号
namespace CH11_2
{
	using System;
	using System.Drawing;
	using System.Collections;
	using System.ComponentModel;
	using System.Windows.Forms;
	using System.Data;

	public class Form1 : System.Windows.Forms.Form
	{
		private System.ComponentModel.Container components;
		private System.Windows.Forms.Button button1;
		private System.Windows.Forms.Label label1;
		private Image image;

		public Form1()
		{
			InitializeComponent();

			// Load the image from a file
			image = Image.FromFile("c:\\windows\\Clouds.bmp");
		}

		public override void Dispose()
		{
			base.Dispose();
			components.Dispose();
		}

		private void InitializeComponent()
		{
			this.components = new System.ComponentModel.Container ();
			this.label1 = new System.Windows.Forms.Label ();
			this.button1 = new System.Windows.Forms.Button ();
			label1.Location = new System.Drawing.Point (16, 24);
			label1.Text = "This is a label";
			label1.Size = new System.Drawing.Size (160, 32);
			label1.TabIndex = 0;
			button1.Location = new System.Drawing.Point (152, 152);
			button1.Size = new System.Drawing.Size (216, 72);
			button1.TabIndex = 1;
			button1.Text = "A Button";
			this.Text = "Form1";
			this.AutoScaleBaseSize = new System.Drawing.Size (5, 13);
			this.ClientSize = new System.Drawing.Size (456, 309);
			this.Paint += new System.Windows.Forms.PaintEventHandler (this.Form1_Paint);
			this.Controls.Add (this.button1);
			this.Controls.Add (this.label1);
		}

		protected void Form1_Paint (object sender, System.Windows.Forms.PaintEventArgs e)
		{
			e.Graphics.DrawImage( image, e.ClipRectangle );
         
		}

		public static void Main(string[] args) 
		{
			Application.Run(new Form1());
		}
	}
}

⌨️ 快捷键说明

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