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 WindowsFormsApplication11
{
public partial class Form1 : Form
{
int x = 10;
public Form1()
{
InitializeComponent();
}
public void mybutton(int i) {
Button mybutton = new Button();
mybutton.Left = 10;
mybutton.Top = 10 + i;
mybutton.Text = "mybutton" + i;
mybutton.Width = 100;
mybutton.Parent = this;
mybutton.Click += new System.EventHandler(button_Click);
}
public void button_Click(object sender, EventArgs e) {
MessageBox.Show(sender + "클릭");
}
private void Form1_Load(object sender, EventArgs e)
{
for (int i = 0; i <5; i++)
{
mybutton(i+x);
x += 50;
}
}
}
}
'Programing > C#' 카테고리의 다른 글
C# 각도구하기,atan (0) | 2017.02.16 |
---|---|
c# 여러개의 오브젝트와의 충돌검사 (0) | 2017.02.15 |
먼곳의 물체의 각도 구하기,ATan2,ATan (0) | 2017.02.15 |
게임 프로그래밍에서 유용하게 쓰이는 함수 (0) | 2017.02.15 |
c# 프로그래밍-키값 알아내기,KeyDown,KeyCode,Keys (0) | 2017.02.14 |