Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want that at runtime when any textbox get leave at same time one more textbox comes under it and when that textbox get leave another textbox comes under it and this process get continued till i want and whole should be at runtime.
Posted

Google[^] is you friend. However, what's the purpose of creating a possibly infinite sequence of TextBoxes?
 
Share this answer
 
Exactly how you do that (and I think it is a very, very poor idea - how do you get out of this loop?) will depend on the environment you are working in: a website will be completely different from a WinForms app for example.
But the principle is:
Handle the LostFocus event for the textbox.
In the event handler, create a new Textbox and add it to the page / form.

For WinForms:
C#
void existingTextBox_LostFocus(object sender, EventArgs e)
    {
    TextBox existing = sender as TextBox;
    if (existing != null)
        {
        TextBox newTextBox = new TextBox();
        newTextBox.LostFocus += new EventHandler(existingTextBox_LostFocus);
        newTextBox.Location = new Point(existing.Location.X, existing.Location.Y + 30);
        newTextBox.Size = existing.Size;
        Controls.Add(newTextBox);
        }
    }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900