ListObject::SetDataBinding Method (Object^, String^, array<String^>^)

 

Binds a ListObject control to a specified data member of a data source, and shows only specified columns of that data member.

Namespace:   Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)

void SetDataBinding(
	Object^ dataSource,
	String^ dataMember,
	... array<String^>^ mappedColumns
)

Parameters

dataSource
Type: System::Object^

The object to use as a data source for the ListObject control.

dataMember
Type: System::String^

The DataMember that specifies the property to bind to within the object returned by the DataSource.

mappedColumns
Type: array<System::String^>^

Names of columns in the data member that you want to display in the ListObject control. To add an unmapped column, include an empty string in the array.

Exception Condition
SetDataBindingFailedException

Could not bind to the specified data source.

ArgumentException

One or more of the arguments are invalid.

ArgumentNullException

The dataSource argument is null.

The dataSource parameter can be any object that implements IList, IListSource, IBindingList, or IEnumerable.

The dataMember parameter must be a property of the data source that returns a bindable collection. For example, a DataSet source has tables as data members.

The following code example creates a DataSet, a DataTable, and a ListObject. It then binds the ListObject to the DataSet and the DataTable, but only includes one of the two possible table columns in the ListObject.

This example is for a document-level customization.

No code example is currently available or this language may not be supported.
Return to top
Show: