ListBindingHelper.GetListItemType Method (Object, String)


Returns the data type of the items in the specified data source.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public static Type GetListItemType(
	object dataSource,
	string dataMember


Type: System.Object

The data source to examine for items.

Type: System.String

The optional name of the property on the data source that is to be used as the data member. This can be null.

Return Value

Type: System.Type

For complex data binding, the Type of the items represented by the dataMember in the data source; otherwise, the Type of the item in the list itself.

This version of the GetListItemType method is used to determine the type of items used in complex or simple data-binding schemes. This static method may be useful in determining whether a proposed data-binding scheme is appropriate before attempting it.

If dataSource is null, the property descriptors cannot be found for the list items of the specified data member, or the property descriptor for the list item is an ICustomTypeDescriptor, then this method returns the type of the Object class.

If dataMember is null or empty, then this method returns the Type of the items in the data source, if it is a list; otherwise, this method returns the Type of the data source itself.

.NET Framework
Available since 2.0
Return to top