iT邦幫忙

2

Day 18視窗應用程式基礎Hello, World 視窗

c#
  • 分享至 

  • xImage
  •  

什麼是 Windows Forms (WinForms)

  • WinForms是.NET Framework / .NET 提供的一個 桌面應用程式開發框架
  • 它讓你可以用拖拉控制項 (Button、Label、TextBox) 的方式,快速建立GUI(圖形介面) 應用程式
  • 適合做簡單的工具軟體、管理系統、資料輸入介面等等

專案結構
https://ithelp.ithome.com.tw/upload/images/20251003/201789252KhZZQXeoW.png

主要檔案功能

  • Program.cs
    專案的進入點 (Main 方法)
    啟動應用程式主迴圈,通常內容大概是:Application.Run(new Form1());

  • Form1.cs
    視窗 (Form) 的程式邏輯檔案
    這裡寫 事件處理程式 (event handler),例如按按鈕後要做什麼

建立檔案
1.對方案點右鍵,選擇加入選擇新增專案
https://ithelp.ithome.com.tw/upload/images/20251003/20178925dM3PAWWbpj.png
2.把所有專案類型改成桌面,選擇Windows Forms APP(.NET Framework)按下一步
https://ithelp.ithome.com.tw/upload/images/20251003/20178925JnBLDlE7iN.png

Label(顯示文字)
1.點擊檢視開啟工具箱
https://ithelp.ithome.com.tw/upload/images/20251003/20178925zKOzLfCtdN.png
2.左邊為控制項右邊為屬性,屬性用來描述物件外觀
https://ithelp.ithome.com.tw/upload/images/20251003/20178925enDHfCMqru.png
3.新增一個Label,點擊屬性的Text欄將文字改為Hello, World!後按執行
https://ithelp.ithome.com.tw/upload/images/20251003/20178925uTu4kUHbU0.png
https://ithelp.ithome.com.tw/upload/images/20251003/201789252psdN6W34u.png


圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言