Herkese merhaba arkadaşlar bugün sizinle VSCode programı üzerinde C# winform yazmayı göstereceğim.
Bildiğiniz üzere bazı cihazlar Visual Studio üzerinde Winform yazarken sorun çıkarıyor. (donanım yetersizliği vb.)
burada da yardımınıza Visual Studio Code yetişiyor.
-ya da böyle bir probleme ihtiyacınız yok sadece vscode temalarını daha çok seviyorsunuz.-
FAZLA UZATMADAN KONUMUZA GEÇELİM.
1.ADIM İndirme ve kurma işlemleri
Visual Studio Code indirme linki
adresinden cihazınıza uygun vscode sürümünü indirebilirsiniz.
2.ADIM Dosya açma ve başlangıç
Cihazınızın istediğiniz bir kısmında istediğiniz isimle boş bir klasör açın.
Sonrasında VSCode ekranına gelip
Bu işlemden sonra ekranda klasör adını içeren "gezgin" isimli bir bar çıkması gerekmektedir.
3.ADIM WinForm eklemek
Terminali gördükten sonra içerisine
Kod:
dotnet new winforms
Gördüğünüz üzere dosyalarımız geldi artık Windows Form yazmaya hazırız.
Bir adet button ekleyip ekrana bildirim göndereceğim.
FORM.CS kodları
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NewProject
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Button button1 = new Button();
button1.Location = new Point(150, 150);
button1.Height = 40;
button1.Width = 300;
button1.BackColor = Color.Black;
button1.ForeColor = Color.Green;
button1.Text = "Bana tıkla";
button1.Name = "button";
button1.Font = new Font("Georgia", 16);
Controls.Add (button1);
button1.Click += new EventHandler(button1_Click);
void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("tebrikler");
}
}
}
}
Form.designer kodları
C#:
namespace NewProject
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(600, 600);
this.Text = "denemeform";
}
#endregion
}
}
EKRAN ÇIKTISI
Terminale dotnet run yazarak kodu run edebilirsiniz!
Visual Studio gibi sürükle bırak tarzı rahat bir kullanımı burada bulamazsınız.
form ögelerini eklemek için kod yazmalısınız.
OKUDUĞUNUZ İÇİN TEŞEKKÜRLER.
Terminale dotnet run yazarak kodu run edebilirsiniz!
Visual Studio gibi sürükle bırak tarzı rahat bir kullanımı burada bulamazsınız.
form ögelerini eklemek için kod yazmalısınız.
OKUDUĞUNUZ İÇİN TEŞEKKÜRLER.