Click here to Skip to main content
15,901,426 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guy i have a form that has alot of controls which includes Textboxes, Each text boxes has a default value. Is the any way i can reload the form without closing it while retianing my textboxes default values.. Thanks
Posted

Hi ,
Check this
You can store the values in load then when you need it you can get it back
Hope it help .

C#
List<string> lst = new List<string>();
private void Form1_Load(object sender, EventArgs e)
{
    foreach (Control ctrl in this.Controls)
    {
        if (ctrl is TextBox)
        {
            lst.Add(((TextBox)ctrl).Text);
        }
    }
}

private void button1_Click(object sender, EventArgs e)
{
    int i = 0;
    foreach (Control ctrl in this.Controls)
    {
        if (ctrl is TextBox)
        {

            ((TextBox)ctrl).Text = lst[i];
            i++;
        }
    }
}


Best Regards
M.Mitwalli
 
Share this answer
 
If your Form is the Start up Form you can use:
C#
Application.Restart();

otherwise there is no method for do that.
 
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