ListObject::SetDataBinding Method (Object^)
Binds a ListObject control to a data source.
Assembly: Microsoft.Office.Tools.Excel (in Microsoft.Office.Tools.Excel.dll)
Parameters
- dataSource
-
Type:
System::Object^
The object to use as a data source for the ListObject control.
| Exception | Condition |
|---|---|
| SetDataBindingFailedException | Could not bind to the specified data source. |
| ArgumentException | The argument is invalid. |
| ArgumentNullException | The dataSource argument is null. |
The data source can be any object that implements IList, IListSource, IBindingList, or IEnumerable, such as a DataTable or a one-dimensional array.
The following code example demonstrates how to use the SetDataBinding method to bind a ListObject to a DataTable. The DataTable contains two columns, which contain the names and ages of employees, and four rows that represent employee entries.
This example is for a document-level customization.
Show: