Avatar of roujesky
roujesky
 asked on

add array of labels to a panel in C# winforms

I want to programmatically create an array of labels and add them to a panel.  None of the labels appear.  

        private Label[] dies = new Label[12];

private void panelAdjDieLevel_Paint(object sender, PaintEventArgs e)
         {
             int height = this.panelAdjDieLevel.Size.Height;
             int length = this.panelAdjDieLevel.Size.Width;
             for (int i = 0; i < 12; i++)
             {
                 dies[i] = new Label();
                 dies[i].Height = 100;// this.Size.Height / 2;
                 dies[i].Width = this.Size.Width / 12;
                 dies[i].Location = new Point(this.panelAdjDieLevel.ClientRectangle.X + (this.panelAdjDieLevel.Size.Height / 2),     this.panelAdjDieLevel.ClientRectangle.Y + (i * dies[i].Width));
                 dies[i].Text = i.ToString();
                 dies[i].BackColor = Color.DarkBlue;
                 dies[i].Visible = true;
                 dies[i].BringToFront();
                 dies[i].BorderStyle = BorderStyle.FixedSingle;

             }
C#.NET Programming

Avatar of undefined
Last Comment
roujesky

8/22/2022 - Mon
kaufmed

Add them to the Controls property of the Panel.
ASKER CERTIFIED SOLUTION
Dmitry G

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
roujesky

ASKER
thanks!
that did it.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy