Home > DeveloperSection > Forums > Working with creating dynamic control in c#
marcel ethan
marcel ethan

Total Post:105

Posted on    June-15-2013 5:27 AM

 C# C# 

 1 Reply(s)
 1073  View(s)
Rate this:
Hi Developers,

How can I create Dynamic Label control using C#?

Sumit Kesarwani

Total Post:378

Posted on    June-15-2013 6:54 AM

Hi Marcel,

Its very easy to create a dynamic control in C#, following, lines of code will solve your problem.

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;


namespace MinimizDemo


    public partial class Form4 : Form


        public Form4()




        int cLeft = 1;


        private void button1_Click(object sender, EventArgs e)




        public System.Windows.Forms.Label AddNewTextBox()


            System.Windows.Forms.Label txt = new System.Windows.Forms.Label();


            txt.Top = cLeft * 25;

            txt.Left = 100;

            txt.Text = "Label " + this.cLeft.ToString();

            cLeft = cLeft + 1;

            return txt;




Don't want to miss updates? Please click the below button!

Follow MindStick