title: c# How to change the visible property of a label created at runtime
body: <p>//Here I create the labels at runtime in one click</p>
  
  <pre><code>Label[] labels = new Label[countresult];
  
  for (int i = 1; i &lt; countresult; i++)
  {
      labels[i] = new Label();
      labels[i].Font = new Font("Arial Rounded MT Bold", 30);
      labels[i].ForeColor = System.Drawing.Color.Red;
      labels[i].AutoSize = true;
      labels[i].Text = "";
  
      //Here I try to assign the value visible = true
  
      labels[i].Visible = true;
      labels[i].TabIndex = i;
  }
  </code></pre>
  
  <p>//In a private void of a timer tick I assign the name of label to var  "a" and I do the 3 methods</p>
  
  <pre><code>string a = string.Format("labels[{0}]", labelscount);
  </code></pre>
  
  <p>//1st method</p>
  
  <pre><code>if (this.Controls.ContainsKey(a))
  {
      this.Controls[a].Visible=false;
  }
  </code></pre>
  
  <p>//2nd method</p>
  
  <pre><code>foreach (Control control in Controls)
  {
      if (control.Name == a)
      {
          control.Visible = false;
      }
  }
  </code></pre>
  
  <p>//3rd method</p>
  
  <pre><code>if (this.Controls[a] is Label) this.Controls[a].Visible=false;
  labelscount++;
  </code></pre>
  
  <p>Unfortunately none works.</p>
  
  <p>Someone know What's happened?</p>