【问题标题】:How can one refresh TabContol inner controls?如何刷新 TabContol 内部控件?
【发布时间】:2017-02-05 22:37:46
【问题描述】:

首先,我读到了这个Reset all the items in a form

在我意识到我的所有控件都在 TabControl 中之前,这很有帮助

然后我尝试了MyTabControl.Controls.Clear(),但这删除了表单中的所有选项卡。

如何在 TabControl 中实现这个Reset all the items in a form

【问题讨论】:

    标签: c# winforms


    【解决方案1】:

    使用:

    foreach (Control c in GetAll(myTabControl))
    {
        ResetAllControls(c);
    }
    

    其中 ResetAllControls 是您的 referenced link

    中的方法
    public static IEnumerable<Control> GetAll(Control control)
    {
        var controls = control.Controls.Cast<Control>();
        return controls.SelectMany(ctrl => GetAll(ctrl))
                                      .Concat(controls);
    }
    

    来自this question的接受答案。

    【讨论】:

    • 真棒男人。它刚刚解决了这个问题。是什么让您认为我们需要使用 GetAll(这也是我的一种方法逻辑。从未见过(我是 C# 新手))
    • 很高兴我能帮上忙
    猜你喜欢
    • 2018-06-03
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-04
    • 1970-01-01
    相关资源
    最近更新 更多