Partager via


ControlCollection.AddListObject Method (ListObject)

Adds a Visual Studio Microsoft.Office.Tools.Excel.ListObject to the control collection based on the specified native Microsoft.Office.Interop.Excel.ListObject.

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

Syntax

'Declaration
Function AddListObject ( _
    listObject As ListObject _
) As ListObject
ListObject AddListObject(
    ListObject listObject
)

Parameters

Return Value

Type: Microsoft.Office.Tools.Excel.ListObject
The Visual Studio Microsoft.Office.Tools.Excel.ListObject that was added to the control collection.

Exceptions

Exception Condition
ArgumentNullException

The listObject argument is nulla null reference (Nothing in Visual Basic), or has zero length.

ControlNameAlreadyExistsException

A ListObject control with the same name has already been added to the ControlCollection instance.

Remarks

You should not call this method directly from your code. Instead, call the ListObjectExtensions.GetVstoObject extension method to obtain a Visual Studio Microsoft.Office.Tools.Excel.ListObject.

The ListObjectExtensions.GetVstoObject extension method uses this method to generate a Visual Studio Microsoft.Office.Tools.Excel.ListObject that corresponds to an instance of a native Microsoft.Office.Interop.Excel.ListObject.

The ListObjectExtensions.GetVstoObject extension method creates an extended Microsoft.Office.Tools.Excel.ListObject only once. It returns the same instance of the existing extended object in subsequent calls. In contrast, AddListObject creates a new extended Microsoft.Office.Tools.Excel.ListObject each time.

.NET Framework Security

See Also

Reference

ControlCollection Interface

AddListObject Overload

Microsoft.Office.Tools.Excel Namespace