public static void RemoveControlByKey(string key, Control.ControlCollection controlCollection) { if (Forms.RobotAutomationHelper.Log) { Console.WriteLine(@"RemoveControlByKey " + key); } if (Forms.RobotAutomationHelper.Log) { Console.WriteLine(key + @" = " + controlCollection.Find(key, false).Length); } while (controlCollection.Find(key, false).Length != 0) { controlCollection.RemoveByKey(key); } }