/// <summary> /// Moves controls from one control collection to the other. /// </summary> /// <param name="source">Source control collection. Will be /// emptied.</param> /// <param name="target">Target collection to be filled.</param> public static void MoveControls(ControlCollection source, ControlCollection target) { int count = source.Count; for (int i=0; i<count; i++) { Control ctrl = source[0]; source.RemoveAt(0); target.Add(ctrl); } }
public void Deny_Unrestricted () { // note: using the same control (as owner) to add results // in killing the ms runtime with a stackoverflow - FDBK36722 ControlCollection cc = new ControlCollection (new Control ()); Assert.AreEqual (0, cc.Count, "Count"); Assert.IsFalse (cc.IsReadOnly, "IsReadOnly"); Assert.IsFalse (cc.IsSynchronized, "IsSynchronized"); Assert.IsNotNull (cc.SyncRoot, "SyncRoot"); cc.Add (control); Assert.IsNotNull (cc[0], "this[int]"); cc.Clear (); cc.AddAt (0, control); Assert.IsTrue (cc.Contains (control), "Contains"); cc.CopyTo (new Control[1], 0); Assert.IsNotNull (cc.GetEnumerator (), "GetEnumerator"); Assert.AreEqual (0, cc.IndexOf (control), "IndexOf"); cc.RemoveAt (0); cc.Remove (control); }