2 // System.Web.UI.WebControls.DataGridColumnCollection
5 // Ben Maurer (bmaurer@novell.com)
7 // (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.Collections;
30 using System.ComponentModel;
32 namespace System.Web.UI.WebControls {
33 public sealed class DataGridColumnCollection : ICollection, IStateManager {
34 public DataGridColumnCollection (DataGrid owner, ArrayList columns)
37 this.columns = columns;
41 public void Add (DataGridColumn column)
44 column.Set_Owner (owner);
46 ((IStateManager) column).TrackViewState ();
49 public void AddAt (int index, DataGridColumn column)
51 columns.Insert (index, column);
52 column.Set_Owner (owner);
54 ((IStateManager) column).TrackViewState ();
62 public void CopyTo (Array array, int index)
64 columns.CopyTo (array, index);
67 public IEnumerator GetEnumerator ()
69 return columns.GetEnumerator ();
72 public int IndexOf (DataGridColumn column)
74 return columns.IndexOf (column);
77 [Obsolete ("figure out what you need with me")]
78 internal void OnColumnsChanged ()
83 public void Remove (DataGridColumn column)
85 columns.Remove (column);
88 public void RemoveAt (int index)
90 columns.RemoveAt (index);
93 void System.Web.UI.IStateManager.LoadViewState (object savedState)
95 object [] o = (object []) savedState;
100 foreach (IStateManager ism in this)
101 ism.LoadViewState (o [i++]);
104 object System.Web.UI.IStateManager.SaveViewState ()
106 object [] o = new object [Count];
109 foreach (IStateManager ism in this)
110 o [i++] = ism.SaveViewState ();
112 foreach (object a in o)
118 void System.Web.UI.IStateManager.TrackViewState ()
121 foreach (IStateManager ism in this)
122 ism.TrackViewState ();
127 get { return columns.Count; }
130 bool IStateManager.IsTrackingViewState {
131 get { return track; }
135 public bool IsReadOnly {
136 get { return columns.IsReadOnly; }
140 public bool IsSynchronized {
141 get { return columns.IsSynchronized; }
145 public DataGridColumn this [int index] {
146 get { return (DataGridColumn) columns [index]; }
150 public object SyncRoot {
151 get { return columns.SyncRoot; }