Valerie Meunier

Valerie Meunier

  • 1.7k
  • 436
  • 18.5k

how to remove programmatically a label dragged from the toolbox?

Jan 5 2022 10:52 PM


i dragged a label from the toolbox and i created programmatically another label:

  private void button1_Click_1(object sender, EventArgs e)
            Label lbl = new Label();
            lbl.Text = "dynamic";
            label1.Text = "toolbox"; // from toolbox

I want to remove both labels from the form. When i run it, i don't see anything in the form, but when i go to view designer, the label 'lbl' is removed but the label 'label1' (from the toolbox) is still there. How can i remove it as well (i also tried with Controls.Remove(label1))?


Answers (3)