java winform程序图标_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

{

///

/// Required designer variable.

///

private System.ComponentModel.IContainer components = null;

///

/// Clean up any resources being used.

///

/// true if managed resources should be disposed; otherwise, false.

protected override void Dispose(bool disposing)

{

if (disposing && (components != null))

{

components.Dispose();

}

base.Dispose(disposing);

}

#region Windows Form Designer generated code

///

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

///

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;

}

}

二、主程序(创建类,并显示):

MyForm11.cs

//csc MyForm11.cs Form1.cs Form1.Designer.cs

using test1;

[assembly: System.Reflection.AssemblyVersion("1.0")]

namespace MyForm11

{

public class MyForm11

{

public static void Main()

{

System.Windows.Forms.Application.EnableVisualStyles();

System.Windows.Forms.Application.Run(new Form1());

}

}

}

三、编译运行:

编译环境:

cmd里运行(vs2017为例):

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat

或将vs2017的开发人员命令提示符固定在任务栏里直接打开,然后进入到源代码目录:

编译运行:

D:\prg\csharp\WinFormsAction\test1>csc MyForm11.cs Form1.cs Form1.Designer.cs

Microsoft(R) Visual C# 编译器 版本 2.10.0.0 (b9fb1610)

版权所有(C) Microsoft Corporation。保留所有权利。

D:\prg\csharp\WinFormsAction\test1>MyForm11.exe

运行截图:

71f26960de3a75e2890bfd24bfecca79.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值