【发布时间】: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?
【问题讨论】:
首先,我读到了这个Reset all the items in a form
在我意识到我的所有控件都在 TabControl 中之前,这很有帮助
然后我尝试了MyTabControl.Controls.Clear(),但这删除了表单中的所有选项卡。
如何在 TabControl 中实现这个Reset all the items in a form?
【问题讨论】:
使用:
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的接受答案。
【讨论】: