Tuesday 29 January 2013

how to create multiple textbox at runtime in c#.net


public void createTextBox()
        {
            TextBox[] txtTextBox = new TextBox[10];

            for (int u = 0; u < txtTextBox.Count(); u++)
            {
                txtTextBox[u] = new TextBox();
            }
            int i = 0;
            foreach (TextBox txt in txtTextBox)
            {
                string name = "TextBoxName" + i.ToString();

                txt.Name = name;
                txt.Text = name;
                txt.Location = new Point(0, 32 + (i * 28));
                txt.Visible = true;
                this.Controls.Add(txt);
                i++;
            }
        }

No comments:

Post a Comment