1.0 开发软件一般有界面载体。
用户使用软件,一般通过良好交互效果的载体进行,比如window应用程序,web浏览器,等等。这里是通过winForm窗体程序开发实现用户和计算机的交互。
首先新建一个窗体应用程序,这里我们选择C#语言。

这里有个细节主要注意.NET版本。

不用使用很新的版本,我这里使用默认的4.5.2即可。

主要开发工具栏如上的3个,如果周围的工具栏消失,可以通过如上调出来。
2.0 程序代码文件树简述

关于程序集信息,体现如下:



3.0 开发
F7和shift+F7可以切换窗体和代码。

窗体会自动生成如下代码:
FormMain.Designer.cs
namespace WFDemo
{
partial class FormMain
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.SuspendLayout();
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(847, 402);
this.Name = "FormMain";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
}
}
FormMain.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WFDemo
{
/// <summary>
/// partial:部分的,限定类本身的组成部分,两个名字一样的partial会在编译的时候编译成一个类(FormMain.Designer.cs)
/// 编译器会自己去完成。
/// </summary>
public partial class FormMain : Form
{
public FormMain()
{
InitializeComponent();
}
}
}
两者其实是一个类。
3.0 属性
窗体放的控件具有各种属性,下面进行属性解释。
在工具栏拖动一个控件button到页面上,F7可以看到源代码如下:
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(206, 73);
this.button1.Name = "测试按钮";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 0;
this.button1.Text = "测试按钮";
this.button1.UseVisualStyleBackColor = true;
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(847, 402);
this.Controls.Add(this.button1);
this.Name = "FormMain";
this.Text = "Form1";
this.ResumeLayout(false);
}
你可以修改其中的内容,会同步影响到控件实际效果。


Text,文字内容,windows10和windows7系统默认靠左,windows8默认居中。

窗口最大化和最小化,值为true时开启,否则禁用。

自动最大化/最小化。

StartPosition:窗体第一次打开时出现的位置。

程序设计完成后,禁止窗口被鼠标拉动。设置为FixedSingle。

窗体图标Icon:


以上只是讲解开发之中用得最多的。

总的来说,就算这么多属性再看不懂,VS也给了非常人性化的中文表述:

如上图,所以不存在看不懂的问题。
END
网友评论