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 WindowsForms01
{
public partial class Panel01 : Form
{
private TextBox txt;
public Panel01()
{
InitializeComponent();
txt = new TextBox();
}
private void button1_Click(object
sender, EventArgs e)
{
//폼 or 패널
this.Controls.Add(txt);//폼의 자식
//this.panel1.Controls.Add(txt);
}
private void button2_Click(object
sender, EventArgs e)
{
this.panel1.Controls.Add(txt);//패널의 자식
}
private void button3_Click(object
sender, EventArgs e)
{
//패널의 자식 컨트롤 삭제
//this.panel1.Controls.Remove(this.txt);
if (this.panel1.Controls.Count > 0)
{
this.panel1.Controls.RemoveAt(0);
}
}
}
}