TableCellCollection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / UI / WebControls / TableCellCollection.cs / 1305376 / TableCellCollection.cs

                            //------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Web.UI.WebControls { 
 
    using System;
    using System.Collections; 
    using System.ComponentModel;
    using System.Drawing.Design;
    using System.Web;
    using System.Web.UI; 

    ///  
    /// Encapsulates the collection of  and  objects within a 
    /// 
    /// control. 
    /// 
    [
    Editor("System.Web.UI.Design.WebControls.TableCellsCollectionEditor, " + AssemblyRef.SystemDesign, typeof(UITypeEditor))
    ] 
    public sealed class TableCellCollection : IList {
 
        ///  
        ///    
        ///       A protected field of type . Represents the 
        ///    
        ///    collection internally.
        /// 
        ///  
        private TableRow owner;
 
 
        /// 
        ///  
        internal TableCellCollection(TableRow owner) {
            this.owner = owner;
        }
 

        ///  
        /// Gets the  
        /// count in the collection.
        ///  
        public int Count {
            get {
                if (owner.HasControls()) {
                    return owner.Controls.Count; 
                }
                return 0; 
            } 
        }
 

        /// 
        ///    
        ///       Gets a  
        ///       referenced by the specified
        ///       ordinal index value. 
        ///     
        /// 
        public TableCell this[int index] { 
            get {
                return(TableCell)owner.Controls[index];
            }
        } 

 
        ///  
        ///    
        ///       Adds the specified  to the end of the collection. 
        ///    
        /// 
        public int Add(TableCell cell) {
            AddAt(-1, cell); 
            return owner.Controls.Count - 1;
        } 
 

        ///  
        ///    
        ///       Adds the specified  to the collection at the specified
        ///       index location.
        ///     
        /// 
        public void AddAt(int index, TableCell cell) { 
            owner.Controls.AddAt(index, cell); 
        }
 

        /// 
        /// 
        public void AddRange(TableCell[] cells) { 
            if (cells == null) {
                throw new ArgumentNullException("cells"); 
            } 
            foreach(TableCell cell in cells) {
                Add(cell); 
            }
        }

 
        /// 
        /// Removes all  controls 
        ///    from the collection. 
        /// 
        public void Clear() { 
            if (owner.HasControls()) {
                owner.Controls.Clear();
            }
        } 

 
        ///  
        ///    Returns an ordinal index value that represents the position of the
        ///       specified  within the collection. 
        /// 
        public int GetCellIndex(TableCell cell) {
            if (owner.HasControls()) {
                return owner.Controls.IndexOf(cell); 
            }
            return -1; 
        } 

 
        /// 
        ///    
        ///       Returns an enumerator of all  controls within the
        ///       collection. 
        ///    
        ///  
        public IEnumerator GetEnumerator() { 
            return owner.Controls.GetEnumerator();
        } 


        /// 
        /// Copies contents from the collection to the specified  with the 
        ///    specified starting index.
        ///  
        public void CopyTo(Array array, int index) { 
            for (IEnumerator e = this.GetEnumerator(); e.MoveNext();)
                array.SetValue(e.Current, index++); 
        }


        ///  
        ///    
        ///       Gets the object that can be used to synchronize access to the 
        ///       collection. In this case, it is the collection itself. 
        ///    
        ///  
        public Object SyncRoot {
            get { return this;}
        }
 

        ///  
        ///     
        ///       Gets a value indicating whether the collection is read-only.
        ///     
        /// 
        public bool IsReadOnly {
            get { return false;}
        } 

 
        ///  
        ///    
        ///       Gets a value indicating whether access to the collection is synchronized 
        ///       (thread-safe).
        ///    
        /// 
        public bool IsSynchronized { 
            get { return false;}
        } 
 

        ///  
        ///    
        ///       Removes the specified  from the
        ///       collection.
        ///     
        /// 
        public void Remove(TableCell cell) { 
            owner.Controls.Remove(cell); 
        }
 

        /// 
        ///    
        ///       Removes the  from the collection at the 
        ///       specified index location.
        ///     
        ///  
        public void RemoveAt(int index) {
            owner.Controls.RemoveAt(index); 
        }

        // IList implementation, required by collection editor
 
        /// 
        object IList.this[int index] { 
            get { 
                return owner.Controls[index];
            } 
            set {
                RemoveAt(index);
                AddAt(index, (TableCell)value);
            } 
        }
 
 
        /// 
        bool IList.IsFixedSize { 
            get {
                return false;
            }
        } 

 
        ///  
        int IList.Add(object o) {
            return Add((TableCell) o); 
        }


        ///  
        bool IList.Contains(object o) {
            return owner.Controls.Contains((TableCell)o); 
        } 

 
        /// 
        int IList.IndexOf(object o) {
            return owner.Controls.IndexOf((TableCell)o);
        } 

 
        ///  
        void IList.Insert(int index, object o) {
            owner.Controls.AddAt(index, (TableCell)o); 
        }


        ///  
        void IList.Remove(object o) {
            owner.Controls.Remove((TableCell)o); 
        } 

    } 
}


// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK