GetListItemType Method (Object, String)
Collapse the table of content
Expand the table of content

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

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

© 2016 Microsoft