Hashey100
Hashey100

Reputation: 984

Dynamic controls do not display

I'm trying to group dynamic labels quite close to each other but when I do and input the text in the labels, they do not display when I run my code. It shows nothing as if it hasn't printed. I was wondering what I can do in order to group dynamic labels close to each other.

1st dynamic Label created:

Label l = new Label();
System.Drawing.Point l0 = new System.Drawing.Point(15, 48 + z);
l.Location = l0;
l.Text = textReader.Value.ToString();
l.AutoSize = true;
l.MaximumSize = new Size(120, 50);
z+= 35;

2nd Dyanmic Label Created:

System.Drawing.Point l1 = new System.Drawing.Point(65, 48 + x);
l2.Location = l1;
l2.Text = textReader.Value.ToString();
l2.AutoSize = true;
l2.MaximumSize = new Size(120, 50);
x += 35;

Upvotes: 3

Views: 964

Answers (1)

Darren
Darren

Reputation: 70814

You have to add the controls to the Form.

Form1.Controls.Add(l);
Form1.Controls.Add(l2);

Upvotes: 7

Related Questions