Create Multiple dynamics lables at runtime

Introduction: This Blog showing how we can create multiple dynamics lables .

We can create the multiple dynamics lables by using for loop.

Example :

public Form1()

        {

            InitializeComponent();

           

            int x = 20; int y = 70;

            for (int i = 0; i < 10; i++)

            {

                 panel1.Controls.Add(new Label { Text = "I am lable", Height = 20, Width = 100, Name = "Label" + i, BackColor = Color.White,Location=new Point(x,y) });

                 panel1.Controls.Add(new TextBox { Text = "I am Textbox", Height = 30, Width = 100, Name = "Text" + i, BackColor = Color.White, Location = new Point(x+100,y) });

                 y = y + 30;

            }

        }