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 How_to_add_controls_dynamically {
public partial class Form1: Form {
int controlleft = 1;
public Form1() {
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e) {
TextBox txt = new TextBox();
this.Controls.Add(txt);
txt.Top = controlleft * 25;
txt.Left = 100;
controlleft = controlleft + 1;
}
}
}In this lesson we will learn how to add controls at run time .I will add only textbox but you can use any .net controls.
