ListBindingHelper.GetList Method (Object, String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Returns an object, typically a list, from the evaluation of a specified data source and optional data member.

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

public static object GetList(
	object dataSource,
	string dataMember


Type: System.Object

The data source from which to find the list.

Type: System.String

The name of the data source property that contains the list. This can be null.

Return Value

Type: System.Object

An Object representing the underlying list if it was found; otherwise, dataSource.

Exception Condition

The specified data member name did not match any of the properties found for the data source.

If the data member is null or an empty string (""), the GetList method returns dataSource.

If dataSource is not a list, GetList returns the value of the dataSource property that matches the dataMember value.

If dataSource is a list, in that it implements either the ICurrencyManagerProvider or IEnumerable interfaces, then the underlying list is obtained by choosing an item from the list and querying that item for the value of the property named by dataMember.

.NET Framework
Available since 2.0
Return to top