Então, criei um panel com scroll e ao apertar o botão nele são criadas 1 textbox e 1 botão, segue o código:
private const int TextBoxX = 5;
private const int TextBoxWidth = 300;
private const int TextBoxY = TextBoxWidth + 10;
public const int ButtonX = TextBoxY + 80;
private int _controlY = 5;
public formCardapio()
{
InitializeComponent();
}
private void btn_adicionar_Click(object sender, EventArgs e)
{
panel1.Controls.AddRange(new Control[]
{
new TextBox
{
Text = txt_cardapio.Text,
Location = new Point(TextBoxX, _controlY),
Size = new Size(300, 20)
},
new TextBox
{
Text = Convert.ToString(txtpreço.Text),
Enabled = true,
Location = new Point(TextBoxY, _controlY),
Size = new Size(80, 20)
},
new Button
{
Text = "Remover",
Location = new Point(ButtonX, _controlY),
Size = new Size(100, 20)
}
});
_controlY += 25;
}
Agora minha duvida é, como eu adiciono um comando ao clicar nesse botão criado, quero que ao clicar nele o textbox criado seja excluido, alguem pode me ajudar
↧