C#으로 코드 작성 중 2 개의 폼이 있고 코드가 텍스트 상자와 해당 확인란을 동적으로 작성합니다. 내가 작성한 코드는 동적 텍스트 상자와 체크 상자를 성공적으로 만듭니다. 그러나 선택한 확인란 행에서 텍스트 상자의 행을 삭제할 수 없습니다.체크 박스로 동적 텍스트 상자 삭제
public void CreateTextBox(int i, StringReader sr)
{
ProductForm form2 = new ProductForm();
_cb = new CheckBox[i];
form2.Visible = true;
form2.Activate();
int x = 10;
int y = 30;
int width = 100;
int height = 20;
for (int n = 0; n < i; n++)
{
String line = sr.ReadLine();
String[] line_ = line.Split(new char[] {'\t'});
String cbName = "chkBox_" + n.ToString();
_cb[n] = new CheckBox();
_cb[n].Name = cbName;
_cb[n].Location = new Point(2, y);
_cb[n].Checked = false;
form2.Controls.Add(_cb[n]);
if (line.Length > 3)
{
for (int row = 0; row < 4; row++)
{
String name = "txtBox_" + row.ToString();
TextBox tb = new TextBox();
tb.Name = name;
tb.Text = line_[row].ToString();
tb.Location = new Point(x, y);
tb.Height = height;
if (row == 1)
{
tb.Width = width * row;
}
if (row == 3)
{
tb.Width = width * 5;
}
else
{
tb.Width = width - 20;
}
x += 10 + width;
form2.Controls.Add(tb);
}
}
x = 10;
y += 25;
}
}
private void DeleteTextBoxButton_Click(object sender, EventArgs e)
{
//Here should I add a code in order to delete dynamically created
//textboxes by clicking checkbox and button
}
}
그래, 뭐가 궁금한가요? – Marlon
winforms와 비슷하지만 winforms/webforms/WPF에 대한 태그인지 여부를 알려주십시오. – Oded
그는 누군가가 자신의 기능에 공란을 채우기를 원한다는 사실이 꽤 분명합니다. – wllmsaccnt