/// <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));
}