[MWF] Don't try to remove non-child control (#19818)
authorEberhard Beilharz <eb1@sil.org>
Thu, 15 May 2014 15:28:57 +0000 (17:28 +0200)
committerEberhard Beilharz <eb1@sil.org>
Thu, 15 May 2014 15:28:57 +0000 (17:28 +0200)
When removing a control from a controls collection we have to
check that the control is part of the collection. Otherwise
we shouldn't do anything.

mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs

index 6aec2cd6da00e4480a96cf22953fc02734f023ce..d763afde5a3248c92c7881e016679594b83a0af9 100644 (file)
@@ -714,7 +714,7 @@ namespace System.Windows.Forms
 
                        public virtual void Remove (Control value)
                        {
-                               if (value == null)
+                               if (value == null || !list.Contains(value))
                                        return;
 
                                all_controls = null;