티스토리 뷰
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;
using System.Data.SqlClient;
namespace DynamicControl
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int C = 1;
private void button3_Click(object sender, EventArgs e)
{
AddNewButton();
}
public System.Windows.Forms.Button AddNewButton()
{
System.Windows.Forms.Button btn = new System.Windows.Forms.Button();
this.Controls.Add(btn);
btn.Top = C * 30;
btn.Left = 300;
btn.Text = "Button" + this.C.ToString();
C = C + 1;
return btn;
}
int A = 1;
private void button1_Click(object sender, EventArgs e)
{
AddNewTextBox();
}
public System.Windows.Forms.TextBox AddNewTextBox()
{
System.Windows.Forms.TextBox txt = new System.Windows.Forms.TextBox();
this.Controls.Add(txt);
txt.Top = A * 30;
txt.Left = 15;
txt.Text = "TextBox" + this.A.ToString();
A = A + 1;
return txt;
}
int B = 1;
private void button2_Click(object sender, EventArgs e)
{
AddNewLabel();
}
public System.Windows.Forms.Label AddNewLabel()
{
System.Windows.Forms.Label lbl = new System.Windows.Forms.Label();
this.Controls.Add(lbl);
lbl.Top = B * 30;
lbl.Left = 200;
lbl.Text = "Label" + this.B.ToString();
B = B + 1;
return lbl;
}
}
}
'프로그래밍 > C#' 카테고리의 다른 글
C# 드래그 앤 드롭 픽쳐 이미지 (0) | 2019.02.28 |
---|---|
C# 구구단 게임 만들기 (0) | 2019.02.28 |
날짜조회하기 및 데이타그리드뷰에 mysql open하지 않고 뷰하기 (0) | 2019.01.23 |
c# 윈폼 콤보박스에 mysql 내용 open하지 않고 불러오기 (0) | 2019.01.23 |
c# mysql Data too long for column 'content' at row 1 (0) | 2019.01.23 |