Hi, I am newbie to vb.net and am developing a windows application for a client.

In that index page, when a first textbox text changed, it should automatically add a new field below the first textbox. And if the second textbox ( child control)text changed, it should automatically add a new field below the second textbox. This will go until the last text field doesn't change.
The textbox created so far, but i cannot set the position for the child controls...its merged.. Have to give the dynamic X,Y points but my code not crossing the level.

I tried the below code.

int x=8;
       int y=8;
    private void Form1_Load(object sender, EventArgs e)
        {

            TextBox txtBox = new TextBox();
            txtBox.Name = "TextBoxName";
            txtBox.Location = new Point(x, y);
            this.panel1.Controls.Add(txtBox);

            txtBox.TextChanged += new EventHandler(this.TextBox_TextChanged);

        }

        private void TextBox_TextChanged(object sender, System.EventArgs e)
        {
            int n = 2;
            for (int i = 1; i < n; i++)
            {
                TextBox tb = new TextBox();
                tb.Location = new System.Drawing.Point(8, 8 + i * 20);
                tb.Name = "TextBoxName" + i.ToString();
                tb.Size = new System.Drawing.Size(184, 20);
                tb.TabIndex = i + 2;                
                this.panel1.Controls.Add(tb);

                IterateThroughChildren(this);               
            }
        }

        private void IterateThroughChildren(Control parentControl)
        {
            
            foreach (Control childControl in parentControl.Controls)
            {
                
                // Find a Particular Control by its Type
                if (childControl.GetType().ToString().Equals("System.Windows.Forms.TextBox"))
                {   
                    childControl.TextChanged += new EventHandler(this.TextBox_TextChanged);
                }
                if (childControl.HasChildren)
                {
                    IterateThroughChildren(childControl);
                }
            }
        }

Any help would be most appreciated.

Thanks

I tried the below code.

I dont think so...
The code you posted is c# and not VB.Net

Please post the code you have so far (not some random copy) and im sure someone will help you.

This article has been dead for over six months. Start a new discussion instead.