Tina J

Hi,

I would like to create a form which enables users to create a new textbox and display it on the form by clicking on a button on the form.

Any suggestions The following code is what I tried but it does not work.

Thanks.

private void button1_Click(object sender, EventArgs e)

{

RichTextBox richTextBox = new RichTextBox();

richTextBox.Location = new Point(120, 60);

richTextBox.Visible = true;

this.Controls.Add(richTextBox);

Application.DoEvents();

}



Re: Windows Forms General Creating new textboxes during runtime

Gavin Jin - MSFT

hiŁ¬try following code.I hope it helps.

private void Form1_Load(object sender, System.EventArgs e)
{
System.windows.form.textbox txt1 = new Textbox();
Controls.add(txt1);
txt1.Size = new System.Drawing.Size(42, 23);
txt1.Location = new System.Drawing.Point(4, 128 + i*26);
}






Re: Windows Forms General Creating new textboxes during runtime

Gavin Jin - MSFT

There is an article about Adding Controls to Windows Forms at Runtime