AutoCompleteStringCollection.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / WinForms / Managed / System / WinForms / AutoCompleteStringCollection.cs / 1305376 / AutoCompleteStringCollection.cs

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

namespace System.Windows.Forms { 
 
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis; 
    using System.Collections;
    using System.Security.Permissions;
    using System.ComponentModel;
 
    /// 
    ///  
    ///    Represents a collection of strings. 
    /// 
    public class AutoCompleteStringCollection : IList { 

        CollectionChangeEventHandler onCollectionChanged;
        private ArrayList data = new ArrayList();
 
        public AutoCompleteStringCollection()
        { 
 
        }
 
        /// 
        /// 
        /// Represents the entry at the specified index of the .
        ///  
        public string this[int index] {
            get { 
                return ((string)data[index]); 
            }
            set { 
                OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, data[index]));
                data[index] = value;
                OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, value));
            } 
        }
 
        ///  
        /// 
        ///    Gets the number of strings in the 
        ///     .
        /// 
        public int Count {
            get { 
                return data.Count;
            } 
        } 

        ///  
        bool IList.IsReadOnly
        {
            get
            { 
                return false;
            } 
        } 

        ///  
        bool IList.IsFixedSize
        {
            get
            { 
                return false;
            } 
        } 

 
        /// 
        /// 
        ///    [To be supplied.]
        ///  
        public event CollectionChangeEventHandler CollectionChanged
        { 
            add 
            {
                this.onCollectionChanged += value; 
            }
            remove
            {
                this.onCollectionChanged -= value; 
            }
        } 
 
        /// 
        ///  
        ///    [To be supplied.]
        /// 
        protected void OnCollectionChanged(CollectionChangeEventArgs e)
        { 
            if (this.onCollectionChanged != null)
            { 
                this.onCollectionChanged(this, e); 
            }
        } 


        /// 
        ///  
        ///    Adds a string with the specified value to the
        ///     . 
        ///  
        public int Add(string value) {
            int index =  data.Add(value); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, value));
            return index;
        }
 
        /// 
        ///  
        /// Copies the elements of a string array to the end of the . 
        /// 
        public void AddRange(string[] value) { 
            if (value == null) {
                throw new ArgumentNullException("value");
            }
            data.AddRange(value); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null));
        } 
 
        /// 
        ///  
        ///    Removes all the strings from the
        ///     .
        /// 
        public void Clear() { 
            data.Clear();
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null)); 
        } 

        ///  
        /// 
        ///    Gets a value indicating whether the
        ///     contains a string with the specified
        ///       value. 
        /// 
        public bool Contains(string value) { 
            return data.Contains(value); 
        }
 
        /// 
        /// 
        /// Copies the  values to a one-dimensional  instance at the
        ///    specified index. 
        /// 
        public void CopyTo(string[] array, int index) { 
            data.CopyTo(array, index); 
        }
 
        /// 
        /// 
        ///    Returns the index of the first occurrence of a string in
        ///       the  . 
        /// 
        public int IndexOf(string value) { 
            return data.IndexOf(value); 
        }
 
        /// 
        /// 
        /// Inserts a string into the  at the specified
        ///    index. 
        /// 
        public void Insert(int index, string value) { 
            data.Insert(index, value); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, value));
        } 

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

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

        ///  
        ///  
        ///     Removes a specific string from the
        ///     . 
        /// 
        public void Remove(string value) {
            data.Remove(value);
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, value)); 
        }
 
        ///  
        /// 
        /// Removes the string at the specified index of the . 
        /// 
        public void RemoveAt(int index) {
            string value = (string)data[index];
            data.RemoveAt(index); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, value));
        } 
 
        /// 
        ///  
        /// Gets an object that can be used to synchronize access to the .
        /// 
        public object SyncRoot {
            [HostProtection(Synchronization=true)] 
            [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
            get { 
                return this; 
            }
        } 

        /// 
        object IList.this[int index] {
            get { 
                return this[index];
            } 
            set { 
                this[index] = (string)value;
            } 
        }

        /// 
        int IList.Add(object value) { 
            return Add((string)value);
        } 
 
        /// 
        bool IList.Contains(object value) { 
            return Contains((string) value);
        }

 
        /// 
        int IList.IndexOf(object value) { 
            return IndexOf((string)value); 
        }
 
        /// 
        void IList.Insert(int index, object value) {
            Insert(index, (string)value);
        } 

        ///  
        void IList.Remove(object value) { 
            Remove((string)value);
        } 

        /// 
        void ICollection.CopyTo(Array array, int index) {
            data.CopyTo(array, index); 
        }
 
        ///  
        public IEnumerator GetEnumerator() {
            return data.GetEnumerator(); 
        }

    }
} 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
//------------------------------------------------------------------------------ 
// 
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// 
//----------------------------------------------------------------------------- 

namespace System.Windows.Forms { 
 
    using System.Diagnostics;
    using System.Diagnostics.CodeAnalysis; 
    using System.Collections;
    using System.Security.Permissions;
    using System.ComponentModel;
 
    /// 
    ///  
    ///    Represents a collection of strings. 
    /// 
    public class AutoCompleteStringCollection : IList { 

        CollectionChangeEventHandler onCollectionChanged;
        private ArrayList data = new ArrayList();
 
        public AutoCompleteStringCollection()
        { 
 
        }
 
        /// 
        /// 
        /// Represents the entry at the specified index of the .
        ///  
        public string this[int index] {
            get { 
                return ((string)data[index]); 
            }
            set { 
                OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, data[index]));
                data[index] = value;
                OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, value));
            } 
        }
 
        ///  
        /// 
        ///    Gets the number of strings in the 
        ///     .
        /// 
        public int Count {
            get { 
                return data.Count;
            } 
        } 

        ///  
        bool IList.IsReadOnly
        {
            get
            { 
                return false;
            } 
        } 

        ///  
        bool IList.IsFixedSize
        {
            get
            { 
                return false;
            } 
        } 

 
        /// 
        /// 
        ///    [To be supplied.]
        ///  
        public event CollectionChangeEventHandler CollectionChanged
        { 
            add 
            {
                this.onCollectionChanged += value; 
            }
            remove
            {
                this.onCollectionChanged -= value; 
            }
        } 
 
        /// 
        ///  
        ///    [To be supplied.]
        /// 
        protected void OnCollectionChanged(CollectionChangeEventArgs e)
        { 
            if (this.onCollectionChanged != null)
            { 
                this.onCollectionChanged(this, e); 
            }
        } 


        /// 
        ///  
        ///    Adds a string with the specified value to the
        ///     . 
        ///  
        public int Add(string value) {
            int index =  data.Add(value); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, value));
            return index;
        }
 
        /// 
        ///  
        /// Copies the elements of a string array to the end of the . 
        /// 
        public void AddRange(string[] value) { 
            if (value == null) {
                throw new ArgumentNullException("value");
            }
            data.AddRange(value); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null));
        } 
 
        /// 
        ///  
        ///    Removes all the strings from the
        ///     .
        /// 
        public void Clear() { 
            data.Clear();
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Refresh, null)); 
        } 

        ///  
        /// 
        ///    Gets a value indicating whether the
        ///     contains a string with the specified
        ///       value. 
        /// 
        public bool Contains(string value) { 
            return data.Contains(value); 
        }
 
        /// 
        /// 
        /// Copies the  values to a one-dimensional  instance at the
        ///    specified index. 
        /// 
        public void CopyTo(string[] array, int index) { 
            data.CopyTo(array, index); 
        }
 
        /// 
        /// 
        ///    Returns the index of the first occurrence of a string in
        ///       the  . 
        /// 
        public int IndexOf(string value) { 
            return data.IndexOf(value); 
        }
 
        /// 
        /// 
        /// Inserts a string into the  at the specified
        ///    index. 
        /// 
        public void Insert(int index, string value) { 
            data.Insert(index, value); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Add, value));
        } 

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

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

        ///  
        ///  
        ///     Removes a specific string from the
        ///     . 
        /// 
        public void Remove(string value) {
            data.Remove(value);
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, value)); 
        }
 
        ///  
        /// 
        /// Removes the string at the specified index of the . 
        /// 
        public void RemoveAt(int index) {
            string value = (string)data[index];
            data.RemoveAt(index); 
            OnCollectionChanged(new CollectionChangeEventArgs(CollectionChangeAction.Remove, value));
        } 
 
        /// 
        ///  
        /// Gets an object that can be used to synchronize access to the .
        /// 
        public object SyncRoot {
            [HostProtection(Synchronization=true)] 
            [SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
            get { 
                return this; 
            }
        } 

        /// 
        object IList.this[int index] {
            get { 
                return this[index];
            } 
            set { 
                this[index] = (string)value;
            } 
        }

        /// 
        int IList.Add(object value) { 
            return Add((string)value);
        } 
 
        /// 
        bool IList.Contains(object value) { 
            return Contains((string) value);
        }

 
        /// 
        int IList.IndexOf(object value) { 
            return IndexOf((string)value); 
        }
 
        /// 
        void IList.Insert(int index, object value) {
            Insert(index, (string)value);
        } 

        ///  
        void IList.Remove(object value) { 
            Remove((string)value);
        } 

        /// 
        void ICollection.CopyTo(Array array, int index) {
            data.CopyTo(array, index); 
        }
 
        ///  
        public IEnumerator GetEnumerator() {
            return data.GetEnumerator(); 
        }

    }
} 

// 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