/// <summary> /// Clears the entire control collection by removing each control /// and disposing it. /// </summary> /// <param name="controlCollection">The control collection to modify.</param> public static void DisposeAll(this Control.ControlCollection controlCollection) { /* Get a list of all current parameter controls */ Control[] listControls = controlCollection.ToArray(); /* Remove each parameter control from the flow layout */ foreach (Control control in listControls) { control.Dispose(); } }