最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C#用記事本編寫(xiě)簡(jiǎn)單WinForm窗體程序

 更新時(shí)間:2019年03月29日 08:37:05   作者:cvMat  
這篇文章主要為大家詳細(xì)介紹了C#用記事本編寫(xiě)簡(jiǎn)單WinForm窗體程序,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

平時(shí)我們編寫(xiě)WinForm程序經(jīng)常使用VS進(jìn)行拖控件的方式,這樣做雖然簡(jiǎn)單,但是無(wú)法深入了解WinForm程序的本質(zhì)。其實(shí),用記事本也可以編寫(xiě)出VS編寫(xiě)的WinForm程序。還是直接看代碼吧:

1、打開(kāi)記事本,寫(xiě)入以下代碼,另存為hello.cs文件

using System;
using System.Windows.Forms;

namespace Hello
{
 public class Form1:Form
 {
  private System.Windows.Forms.Button btnClose;
  public Form1()
  {
    this.Text = "Form1窗體";
    btnClose = new System.Windows.Forms.Button();
    //將窗體掛起
    this.SuspendLayout();

    //設(shè)置按鈕屬性
    this.btnClose.Location = new System.Drawing.Point(20,20);
    this.btnClose.Size = new System.Drawing.Size(100,25);
    this.btnClose.Name = "btnClose";
    this.btnClose.Text = "按鈕";

    this.btnClose.UseVisualStyleBackColor = true;

    //設(shè)置按鈕控件點(diǎn)擊事件
    this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
    //將構(gòu)造的控件添加到窗體Controls控件集合
    this.Controls.Add(btnClose);
  }
  //按鈕點(diǎn)擊事件
   private void btnClose_Click(object sender,EventArgs e)
   {
   this.Close();
   }
 }
 public class Program
 {
  //程序入口
  public static void Main()
  {
   Application.Run(new Form1());
  }
 }
}

2、在Windows搜索框輸入 cmd,打開(kāi)控制臺(tái),輸入以下代碼切換目錄

cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

3、目錄切換完畢后,輸入以下代碼運(yùn)行

csc.exe /out:e:\hello.exe e:\hello.cs

/out:e:\hello.exe用于指定可執(zhí)行文件存放的目錄和名稱
e:\hello.cs用于指定源文件的文件路徑


以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

新竹市| 桐柏县| 介休市| 沙雅县| 哈尔滨市| 法库县| 承德市| 盖州市| 左权县| 油尖旺区| 英超| 普宁市| 嫩江县| 信阳市| 兴海县| 葫芦岛市| 阳西县| 东方市| 安远县| 精河县| 类乌齐县| 密云县| 突泉县| 彩票| 鄂尔多斯市| 东宁县| 盐津县| 博湖县| 尉氏县| 罗田县| 湖南省| 交城县| 普格县| 辽宁省| 于田县| 崇义县| 新干县| 南江县| 宁城县| 通海县| 靖安县|