2 // System.Web.UI.WebControls.TableRowCollection.cs
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 using System.ComponentModel;
30 using System.Collections;
32 namespace System.Web.UI.WebControls {
34 [Editor ("System.Web.UI.Design.WebControls.TableRowsCollectionEditor, " + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
35 public sealed class TableRowCollection : IList, ICollection, IEnumerable
40 internal TableRowCollection (Table table)
43 throw new ArgumentNullException ("table");
50 get { return cc.Count; }
53 public bool IsReadOnly {
54 get { return false; } // documented as always false
57 public bool IsSynchronized {
58 get { return false; } // documented as always false
61 public TableRow this [int index] {
62 get { return (TableRow) cc [index]; }
65 public object SyncRoot {
66 get { return this; } // as documented
69 public int Add (TableRow row)
72 throw new NullReferenceException (); // .NET compatibility
73 if (row.TableRowSectionSet)
74 owner.GenerateTableSections = true;
76 int index = cc.IndexOf (row);
84 public void AddAt (int index, TableRow row)
87 throw new NullReferenceException (); // .NET compatibility
89 if (cc.IndexOf (row) < 0) {
90 if (row.TableRowSectionSet)
91 owner.GenerateTableSections = true;
93 cc.AddAt (index, row);
97 public void AddRange (TableRow[] rows)
99 foreach (TableRow tr in rows) {
101 throw new NullReferenceException (); // .NET compatibility
103 if (cc.IndexOf (tr) < 0) {
104 if (tr.TableRowSectionSet)
105 owner.GenerateTableSections = true;
114 owner.GenerateTableSections = false;
118 public void CopyTo (Array array, int index)
120 cc.CopyTo (array, index);
123 public IEnumerator GetEnumerator ()
125 return cc.GetEnumerator ();
128 public int GetRowIndex (TableRow row)
130 return cc.IndexOf (row);
133 internal void RowTableSectionSet ()
135 owner.GenerateTableSections = true;
138 public void Remove (TableRow row)
141 row.Container = null;
145 public void RemoveAt (int index)
147 TableRow row = this [index] as TableRow;
149 row.Container = null;
155 // implements IList but doesn't make some members public
157 bool IList.IsFixedSize {
158 get { return false; }
161 object IList.this [int index] {
162 get { return cc [index]; }
164 cc.AddAt (index, (TableRow)value);
165 cc.RemoveAt (index + 1);
170 int IList.Add (object value)
172 return Add (value as TableRow);
175 bool IList.Contains (object value)
177 return cc.Contains (value as TableRow);
180 int IList.IndexOf (object value)
182 return cc.IndexOf (value as TableRow);
185 void IList.Insert (int index, object value)
187 AddAt (index, value as TableRow);
190 void IList.Remove (object value)
192 Remove (value as TableRow);