3 Replies - 60698 Views - Last Post: 20 June 2008 - 09:17 AM Rate Topic: **--- 1 Votes

#1 thaveen  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 19-June 08

How to dynamically create TextBox at runtime

Posted 19 June 2008 - 10:54 PM

How to create multiple text box dynamically using .net
Is This A Good Question/Topic? 0
  • +

Replies To: How to dynamically create TextBox at runtime

#2 rgfirefly24  Icon User is offline

  • D.I.C Lover
  • member icon


Reputation: 267
  • View blog
  • Posts: 1,477
  • Joined: 07-April 08

Re: How to dynamically create TextBox at runtime

Posted 20 June 2008 - 05:29 AM

View Postthaveen, on 19 Jun, 2008 - 10:54 PM, said:

How to create multiple text box dynamically using .net



using the new keyword. I.E

Textbox textbox1 = new Textbox();


Was This Post Helpful? 0
  • +
  • -

#3 zakary  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 27
  • View blog
  • Posts: 427
  • Joined: 15-February 05

Re: How to dynamically create TextBox at runtime

Posted 20 June 2008 - 08:38 AM

for multiple you can create an array of Textbox
private System.Windows.Forms.TextBox[] textboxes;


then create a loop to create the textboxes and set there location
textboxes = new System.Windows.Forms.TextBox[2];
int cnt=0;
foreach (System.Windows.Forms.TextBox textbox in textboxes)
{
      // the location on the form. you may need to play with this
      // and it should change for each textbox
      textbox.Location = new System.Drawing.Point(88, 50); 
      textbox.Name = "textbox"+cnt.ToString();
      textbox.Size = new System.Drawing.Size(173, 20);
      textbox.TabIndex = cnt;
      textbox.Visible = true; 
      cnt++;
}


This post has been edited by zakary: 20 June 2008 - 08:38 AM

Was This Post Helpful? 1

#4 Jayman  Icon User is offline

  • Student of Life
  • member icon

Reputation: 418
  • View blog
  • Posts: 9,532
  • Joined: 26-December 05

Re: How to dynamically create TextBox at runtime

Posted 20 June 2008 - 09:17 AM

Topic renamed to be more descriptive.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1