Shankar M

Shankar M

  • NA
  • 3k
  • 3.3m

Using Statement

Jan 30 2014 12:23 AM
Dear Experts,
 
I am using "using" statements to create labels dynamically.So the objects can be disposed after added to flow layout panel. Here is my code.
 The problem is the control created are not added to the flow layout panel.
 
Code :
 
for (int j = 0;j<10 ; j++)
{
using (Label lbl = new Label())
{
lbl.Text = "Label" + j.ToString();
lbl.Name = "Label" + j.ToString();
lbl.Font = new Font("verdana", 6.0f);
lbl.Size = new Size(43, 8);
//lbl.Click +=new EventHandler(lbl_Click);
//flowLayoutPanel1.Margin = new Padding(0, 0, 0, 0);
//flowLayoutPanel1.Padding = new Padding(0, 0, 0, 0);
this.flowLayoutPanel1.Controls.Add(lbl);
}
}
 
Any help appreciated.
 
Thanks, Shankar M
 

Answers (4)