如何重新加载窗口表单 [英] How to Reload a Window Form

查看:108
本文介绍了如何重新加载窗口表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含很多控件的窗体,其中包括文本框,每个文本框都有一个默认值.是在重新设置文本框默认值的同时不关闭表格的任何方式.谢谢

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

推荐答案


检查此
您可以将值存储在负载中,然后在需要时将其取回
希望对您有所帮助.

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

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++;
        }
    }
}



最好的问候
M.Mitwalli



Best Regards
M.Mitwalli


如果您的表格是启动表格,则可以使用:
If your Form is the Start up Form you can use:
Application.Restart();


否则就没有办法.


otherwise there is no method for do that.


这篇关于如何重新加载窗口表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆