17°

C#图形界面WinForm 入门(HelloWorld)

一、窗口设计Form1:

两个文件:

Form1.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace test1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }

    private void label1_Click(object sender, EventArgs e)
    {

    }
}

}

Form1.Designer.cs

namespace test1
{
	partial class Form1
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.IContainer components = null;
	/// &lt;summary&gt;
	/// Clean up any resources being used.
	/// &lt;/summary&gt;
	/// &lt;param name="disposing"&gt;true if managed resources should be disposed; otherwise, false.&lt;/param&gt;
	protected override void Dispose(bool disposing)
	{
		if (disposing &amp;&amp; (components != null))
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	#region Windows Form Designer generated code

	/// &lt;summary&gt;
	/// Required method for Designer support - do not modify
	/// the contents of this method with the code editor.
	/// &lt;/summary&gt;
	private void InitializeComponent()
	{
        this.label1 = new System.Windows.Forms.Label();
        this.SuspendLayout();
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(112, 113);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(37, 15);
        this.label1.TabIndex = 0;
        this.label1.Text = "你好";
        this.label1.Click += new System.EventHandler(this.label1_Click);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(282, 253);
        this.Controls.Add(this.label1);
        this.Name = "Form1";
        this.Text = "Form1";
        this.ResumeLayout(false);
        this.PerformLayout();

	}

    #endregion

    private System.Windows.Forms.Label label1;
}

}

运行截图:

本文由【wangxuwei】发布于开源中国,原文链接:https://my.oschina.net/u/2245781/blog/3136292

全部评论: 0

    我有话说: