ITypedList.GetItemProperties(PropertyDescriptor[]) 方法

定义

返回 PropertyDescriptorCollection,其表示每一项上用于绑定数据的属性。Returns the PropertyDescriptorCollection that represents the properties on each item used to bind data.

public:
 System::ComponentModel::PropertyDescriptorCollection ^ GetItemProperties(cli::array <System::ComponentModel::PropertyDescriptor ^> ^ listAccessors);
public System.ComponentModel.PropertyDescriptorCollection GetItemProperties (System.ComponentModel.PropertyDescriptor[] listAccessors);
abstract member GetItemProperties : System.ComponentModel.PropertyDescriptor[] -> System.ComponentModel.PropertyDescriptorCollection
Public Function GetItemProperties (listAccessors As PropertyDescriptor()) As PropertyDescriptorCollection

参数

listAccessors
PropertyDescriptor[]

要在组合中查找的可绑定的 PropertyDescriptor 对象的数组。An array of PropertyDescriptor objects to find in the collection as bindable. 它可以是 nullThis can be null.

返回

PropertyDescriptorCollection,其表示每一项上用于绑定数据的属性。The PropertyDescriptorCollection that represents the properties on each item used to bind data.

示例

下面的代码示例演示如何实现GetItemProperties方法。The following code example demonstrates how to implement the GetItemProperties method. 有关完整的代码清单, 请参阅如何:实现 ITypedList 接口For a full code listing, see How to: Implement the ITypedList Interface.

public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
{
    PropertyDescriptorCollection pdc;

    if (listAccessors!=null && listAccessors.Length>0)
    {
        // Return child list shape.
        pdc = ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType);
    }
    else
    {
        // Return properties in sort order.
        pdc = properties;
    }

    return pdc;
}
Public Function GetItemProperties(ByVal listAccessors() As System.ComponentModel.PropertyDescriptor) As System.ComponentModel.PropertyDescriptorCollection Implements System.ComponentModel.ITypedList.GetItemProperties

    Dim pdc As PropertyDescriptorCollection

    If (Not (listAccessors Is Nothing)) And (listAccessors.Length > 0) Then
        ' Return child list shape
        pdc = ListBindingHelper.GetListItemProperties(listAccessors(0).PropertyType)
    Else
        ' Return properties in sort order
        pdc = properties
    End If

    Return pdc

End Function

注解

如果参数不null为, 则它通常包含一个属性说明符, 该说明符标识要为实现ITypedList的对象检索的容器的列表。 listAccessorsIf the listAccessors parameter is not null, it typically contains a property descriptor that identifies a list of containers to retrieve for the object that implements ITypedList. 例如, DataSet包含两个myCustomers表的, 以及myOrders两个表之间myCustOrders的关系。For example, a DataSet containing two tables, myCustomers and myOrders, with a relationship between them called myCustOrders. DataView如果创建myCustomers要查看myCustomers的对象, 则通过调用GetItemProperties方法并null返回中的列的属性说明符。If you create a DataView object to view myCustomers, then calling the GetItemProperties method with null returns the property descriptors for the columns in myCustomers. 因此, 返回的属性描述符之一是的属性描述符myCustOrders, 就像使用myCustOrders包含的属性说明符的GetItemProperties列表访问器数组调用方法时, 将返回属性说明符对于myOrdersAs a result, one of the returned property descriptors is a property descriptor for myCustOrders, just as calling the GetItemProperties method with a list accessor array containing the property descriptors for myCustOrders will return the property descriptors for myOrders.

适用于

另请参阅