System.ComponentModel.PropertyDescriptorCollection.Insert C# (CSharp) Method

Insert() public method

public Insert ( int index, PropertyDescriptor value ) : void
index int
value PropertyDescriptor
return void
        public void Insert(int index, PropertyDescriptor value) {
            if (readOnly) {
                throw new NotSupportedException();
            }

            EnsureSize(propCount + 1);
            if (index < propCount) {
                Array.Copy(properties, index, properties, index + 1, propCount - index);   
            }
            properties[index] = value;
            propCount++;
        }
        

Usage Example

        PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[] attributes)
        {
            PropertyDescriptorCollection pdc = new PropertyDescriptorCollection(new PropertyDescriptor[0]);
            foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(this))
            {
                pdc.Add(pd);
            }

            //put Position property on top
            PropertyDescriptor posd = pdc["pPosition"];
            pdc.Remove(posd);
            pdc.Insert(0, posd);

            foreach (String key in CustomProperties.Keys)
            {
                pdc.Add(new DictionaryPropertyDescriptor(CustomProperties, key, attributes));
            }
            return pdc;
        }
All Usage Examples Of System.ComponentModel.PropertyDescriptorCollection::Insert