Kod İle Oluşturulan Butona Görev Atama C#


** Form1 yüklendiğinde belirtilen boyutta , belirtilen koordinata buton oluşturulur.Ve oluşturulan butona tıklandğında label1’e Buton Tıklandı yazar.




Kod:
using System;


using System.Collections.Generic;


using System.ComponentModel;


using System.Data;


using System.Drawing;


using System.Linq;


using System.Text;


using System.Windows.Forms;


namespace kodla_olusturulan_butona_islem_yaptırma


{


public partial class Form1 : Form


{


public Form1()


{


InitializeComponent();


}


private void yaz (object sender,System.EventArgs e)


{


label1.Text = "Buton tıklandı";


}


private void Form1_Load(object sender, EventArgs e)


{


Button dugme = new Button();


dugme.Top = 50;


dugme.Left = 70;


dugme.Width = 100;


dugme.Text = "Buton1";


dugme.Click += new EventHandler(yaz);


this.Controls.Add(dugme);


}


}


}