hey im trying to remove all my custom controls from my form, but not all of the are removed. i have to call my lear function a few times, depending on the number of controls. All of the controls are created at runtime and have different names.
Is there a better way to remove the controls from a form?Code:private void ClearResults() { foreach(Control c in this.pMain.Controls) { if(c is ResultsItem) { #if DEBUG Debug.WriteLine("Disposing of " + c.Name.ToString()); #endif c.Visible = false; c.Dispose(); } } }
Thanks




Reply With Quote