2 // System.Web.UI.ControlCollection.cs
4 // Duncan Mak (duncan@ximian.com)
10 using System.Collections;
12 namespace System.Web.UI {
14 public class ControlCollection : ICollection, IEnumerable
16 ArrayList list = new ArrayList ();
19 public ControlCollection (Control owner)
22 throw new ArgumentException ();
28 get { return list.Count; }
31 public bool IsReadOnly {
32 get { return list.IsReadOnly; }
35 public bool IsSynchronized {
36 get { return list.IsSynchronized; }
39 public virtual Control this [int index] {
40 get { return list [index] as Control; }
43 protected Control Owner {
47 public object SyncRoot {
48 get { return list.SyncRoot; }
51 public virtual void Add (Control child)
54 throw new ArgumentNullException ();
56 throw new HttpException ();
59 owner.AddedControl (child, list.Count - 1);
62 public virtual void AddAt (int index, Control child)
64 if (child == null) // maybe we should check for ! (child is Control)?
65 throw new ArgumentNullException ();
67 if ((index < -1) || (index > Count))
68 throw new ArgumentOutOfRangeException ();
71 throw new HttpException ();
77 owner.AddedControl (child, index);
81 public virtual void Clear ()
86 public virtual bool Contains (Control c)
88 return list.Contains (c);
91 public void CopyTo (Array array, int index)
93 list.CopyTo (array, index);
96 public IEnumerator GetEnumerator ()
98 return list.GetEnumerator ();
101 public virtual int IndexOf (Control c)
103 return list.IndexOf (c);
106 public virtual void Remove (Control value)
109 owner.RemovedControl (value);
112 public virtual void RemoveAt (int index)
115 throw new HttpException ();
117 Control value = (Control) list [index];
118 list.RemoveAt (index);
119 owner.RemovedControl (value);