Results 1 to 11 of 11

Thread: Dynamically Adding textboxes [Resolved]

Threaded View

  1. #1

    Thread Starter
    Member
    Join Date
    Sep 2002
    Location
    London
    Posts
    63

    Dynamically Adding textboxes [Resolved]

    Hi, my code creates 10 textboxes, or more if I change the for loop with a variable instead of 10.

    All the textboxes are dynamically added. My question is how can I address say the third text box. I.e. in my code I would want to assign different text to each textbox afterwards.

    heres my code.

    int iLeft = 16;
    int iTop = 16;

    TextBox txtInput;

    for (int i=0;i < 10; i++)
    {
    txtInput = new TextBox();
    txtInput.Location = new Point(iLeft,iTop);
    txtInput.Size = new Size(100,35);
    txtInput.TabIndex = 1;
    txtInput.BorderStyle =0;
    txtInput.BackColor = Color.Blue;
    txtInput.ForeColor = Color.White;
    txtInput.Text = "Input Field #" + i.ToString();
    this.Controls.Add(txtInput);
    iTop += 30;

    }
    Last edited by Genie; Apr 28th, 2003 at 09:49 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width