ITypedList.GetItemProperties(PropertyDescriptor[]) 方法

定義

傳回代表繫結資料所用各項目屬性的 PropertyDescriptorCollectionReturns 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.

傳回

代表繫結資料所用各項目屬性的 PropertyDescriptorCollectionThe 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 , 其中包含兩個數據表 ( myCustomersmyOrders), 其在呼叫myCustOrders之間具有關聯性。For example, a DataSet containing two tables, myCustomers and myOrders, with a relationship between them called myCustOrders. 如果您建立DataViewmyCustomers查看myCustomers的物件, 然後使用null呼叫GetItemProperties方法, 會在中傳回資料行的屬性描述元。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元, 如同使用包含的屬性描述元的清單存取子陣列來GetItemProperties呼叫方法, myCustOrders將傳回屬性描述元。適用myOrders于。As 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.

適用於

另請參閱