
一.創建csproj文件Project SdkMicrosoft.NET.Sdk PropertyGroup Version0.0.1/Version TargetFrameworksnet472/TargetFrameworks Platformsx64/Platforms OutputTypeWinExe/OutputType !--指定輸出exe名稱,輸出exe路徑-- DebugTypenone/DebugType DebugSymbolsfalse/DebugSymbols AppendTargetFrameworkToOutputPathfalse/AppendTargetFrameworkToOutputPath AppendRuntimeIdentifierToOutputPathfalse/AppendRuntimeIdentifierToOutputPath OutputPathD:\work/OutputPath /PropertyGroup !--指定使用C#接口-- ItemGroup Reference IncludeSystem / Reference IncludeSystem.Core / Reference IncludeSystem.Design / Reference IncludeSystem.Xml.Linq / Reference IncludeSystem.Data.DataSetExtensions / Reference IncludeMicrosoft.CSharp / Reference IncludeSystem.Data / Reference IncludeSystem.Deployment / Reference IncludeSystem.Drawing / Reference IncludeSystem.Net.Http / Reference IncludeSystem.Windows.Forms / Reference IncludeSystem.Xml / /ItemGroup /Project二.創建Test.cs[STAThread] public static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form()); }三.添加控件public void AddWidget() { Label label new Label(); this.Controls.Add(label); }四.WinForm窗體事件回調Button button new Button(); button.Click OnOkButtonClicked; public void OnOkButtonClicked(object sender, EventArgs e) { MessageBox.Show(OK BUTTON CLICKED!, Warning); }五.窗體循環System.Windows.Forms.TimerTimer timer new Timer(); timer.Enabled true; timer.Interval 10; timer.Tick OnTick; timer.Start(); #重寫OnTick函數 public void OnTick(object sender, EventArgs e) { }