#:sdk Microsoft.NET.Sdk #:property TargetFramework=net10.0-windows #:property UseWindowsForms=true #:property OutputType=WinExe #:property PublishAot=false using System; using System.Drawing; using System.Windows.Forms; static class Program { [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetHighDpiMode(HighDpiMode.SystemAware); var count = 0; var label = new Label { Text = "Count: 0", AutoSize = true, Margin = new Padding(10, 13, 10, 10) }; var dec = new Button { Text = "-", Width = 40 }; var inc = new Button { Text = "+", Width = 40 }; dec.Click += (_, _) => label.Text = $"Count: {--count}"; inc.Click += (_, _) => label.Text = $"Count: {++count}"; var row = new FlowLayoutPanel { FlowDirection = FlowDirection.LeftToRight, AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, WrapContents = false, Anchor = AnchorStyles.None, }; row.Controls.Add(dec); row.Controls.Add(label); row.Controls.Add(inc); var host = new TableLayoutPanel { Dock = DockStyle.Fill, ColumnCount = 1, RowCount = 1 }; host.Controls.Add(row, 0, 0); var form = new Form { Text = "Counter Example", ClientSize = new Size(640, 420) }; form.Controls.Add(host); Application.Run(form); } }