System.Windows.Forms.ListBindingHelper.GetListItemProperties C# (CSharp) Method

GetListItemProperties() public static method

public static GetListItemProperties ( object dataSource, string dataMember, Array listAccessors ) : System.Windows.Forms.PropertyDescriptorCollection
dataSource object
dataMember string
listAccessors Array
return System.Windows.Forms.PropertyDescriptorCollection
        public static PropertyDescriptorCollection GetListItemProperties(object dataSource, string dataMember, PropertyDescriptor[] listAccessors) {
            dataSource = GetList(dataSource);

            if (!String.IsNullOrEmpty(dataMember)) {
                // Find the property on the data source specified by the data member
                PropertyDescriptorCollection dsProps = ListBindingHelper.GetListItemProperties(dataSource);
                PropertyDescriptor dmProp = dsProps.Find(dataMember, true);

                // Error: Property not found - data member is invalid
                if (dmProp == null) {
                    throw new System.ArgumentException(SR.GetString(SR.DataSourceDataMemberPropNotFound, dataMember));
                }

                // Add the data member property to the list accessors
                int len = (listAccessors == null) ? 1 : (listAccessors.Length + 1);
                PropertyDescriptor[] listAccessors2 = new PropertyDescriptor[len];
                listAccessors2[0] = dmProp;
                for (int i = 1; i < len; ++i) {
                    listAccessors2[i] = listAccessors[i - 1];
                }

                // Replace old accessors with new accessors
                listAccessors = listAccessors2;
            }

            return GetListItemProperties(dataSource, listAccessors);
        }

Same methods

ListBindingHelper::GetListItemProperties ( object list ) : System.Windows.Forms.PropertyDescriptorCollection
ListBindingHelper::GetListItemProperties ( object list, Array listAccessors ) : System.Windows.Forms.PropertyDescriptorCollection

Usage Example

Esempio n. 1
0
        /// <include file='doc\ListBindingHelper.uex' path='docs/doc[@for="ListBindingHelper.GetListItemProperties2"]/*' />
        public static PropertyDescriptorCollection GetListItemProperties(object dataSource, string dataMember, PropertyDescriptor[] listAccessors)
        {
            dataSource = GetList(dataSource);

            if (!string.IsNullOrEmpty(dataMember))
            {
                // Find the property on the data source specified by the data member
                PropertyDescriptorCollection dsProps = ListBindingHelper.GetListItemProperties(dataSource);
                PropertyDescriptor           dmProp  = dsProps.Find(dataMember, true);

                // Error: Property not found - data member is invalid
                if (dmProp == null)
                {
                    throw new System.ArgumentException(string.Format(SR.DataSourceDataMemberPropNotFound, dataMember));
                }

                // Add the data member property to the list accessors
                int len = (listAccessors == null) ? 1 : (listAccessors.Length + 1);
                PropertyDescriptor[] listAccessors2 = new PropertyDescriptor[len];
                listAccessors2[0] = dmProp;
                for (int i = 1; i < len; ++i)
                {
                    listAccessors2[i] = listAccessors[i - 1];
                }

                // Replace old accessors with new accessors
                listAccessors = listAccessors2;
            }

            return(GetListItemProperties(dataSource, listAccessors));
        }
All Usage Examples Of System.Windows.Forms.ListBindingHelper::GetListItemProperties