Add New textbox At Runtime & Access That Textbox Value


 

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
            //Decalre As Global For Use Anywhere...
            TextBox txtMyNewTextBox = new TextBox();

            private void button1_Click(object sender, EventArgs e)
            {
                        //Set The Location On The Form Using X & Y Axes...
                        txtMyNewTextBox.Location = new Point(12, 12);

                        //It Will Add New Textbox To Form Runtime...
                        this.Controls.Add(txtMyNewTextBox);
            }

            //Using Below You Can Retrieve value Of New Textbox...
            private void button2_Click(object sender, EventArgs e)
            {

                        //You Can Store It In Variable….

                        string store= txtMyNewTextBox.Text;

 

//You Can Store It In Another Textbox Also…
                        TextBox1.Text = txtMyNewTextBox.Text;
            }
   }

}