public void Clear() { if (layoutPanel.Controls.Count > 0) { //Copy the controls into an array, since the Dispose calls will remove them from the source list UserControl[] properties = new UserControl[layoutPanel.Controls.Count]; layoutPanel.Controls.CopyTo(properties, 0); foreach (UserControl property in properties) { IFormProperties propertyBase = property as IFormProperties; if (propertyBase != null) { propertyBase.Clear(); } } layoutPanel.Controls.Clear(); } }