问题
got a very simple question which I can't seem to find any answer for.
In a standard WinForms application, is there anything I can iterate through in order to find all the relevant input items to reset in a given form?
EG, iterate through all inputs and set TextBox.Text = "", ComboBox.SelectedItem = -1, etc ...
If this was a Web application it'd be easy, I'd just iterate through the Controls collection in the Page. But a Console application doesn't have a Page element, and I've looked at the "this" element, and can't find any way to iterate through the inputs.
回答1:
Recursively loop through the Controls
collection.
回答2:
foreach (Control ctrl in Controls)
{
ctrl.ResetText();
}
Control ResetText
来源:https://stackoverflow.com/questions/9845489/resetting-all-fields-to-initial-state-in-c-net-winforms-application