-1

First, I read this Reset all the items in a form

It was a great help until I realised all my controls are inside a TabControl containing itself several tabs in which there are all the common controls i.e. textbox, datetimepicker, datagrigview, etc....

Then I tried MyTabControl.Controls.Clear() but this deleted all tabs in the form.

How can I implement this Reset all the items in a form in a TabControl ?

Community
  • 1
  • 1
Kurt Miller
  • 567
  • 1
  • 8
  • 23

1 Answers1

2

use:

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

in which ResetAllControls is the method in your referenced link and

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

from the accepted answer of this question.

Community
  • 1
  • 1
rmojab63
  • 3,513
  • 1
  • 15
  • 28