[[oktatas:programozás:csharp:dotnetcore|< .Net Core]] ====== .Net Core - Windows Forms ====== * **Szerző:** Sallai András * Copyright (c) 2022, Sallai András * Szerkesztve: 2024 * Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]] * Web: https://szit.hu ===== Projekt létrehozása ===== Linuxon .Net Core 7.0 esetén nem működik. dotnet new winforms ===== A projekt ===== namespace app01; static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); Application.Run(new Form1()); } } namespace app03; public partial class Form1 : Form { public Form1() { InitializeComponent(); } } namespace app03; 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.components = new System.ComponentModel.Container(); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); this.Text = "Form1"; } #endregion } WinExe net6.0-windows enable true enable Form ===== Gomb ===== namespace app01; public partial calss Form1 : Form { Button button = new Button(); public Form1() { button.Text = "Mehet"; button.Location = new Point(50, 50); button.Click += new EventHandler(Button_Click); this.Controls.Add(button); this.Width = 400; this.Height = 300; this.Show(); } private void Button_Click(object? sender, EventArgs e) { MessageBox.Show("Működik"); } }