Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

How to: Add ListObject Controls to Worksheets

Note Required applications

The features in this topic are available only if you have the required applications installed.

For more information, see Features Available by Product Combination.

  • One of these development environments:

    VSTO 2005

    -or-

    Visual Studio Team System

  • Microsoft Office 2003

There are several ways to add ListObject controls to your Microsoft Office Excel 2003 worksheets.

NoteNote

The dialog boxes and menu commands you see might differ from those described in Help depending on your active settings or edition. To change your settings, choose Import and Export Settings on the Tools menu. For more information, see Visual Studio Settings.

  • From within Excel.

    You can add the ListObject control to your worksheet in the same manner you would add a list from within the application. The advantage of using this method is that you can name your control at the time you create it.

  • From the Visual Studio Toolbox.

    You can drag the ListObject control from the Toolbox to your document. You might want to use this method if you are already using the Toolbox to add Windows Forms controls to your document.

  • From the Data Sources Window.

    You can drag the ListObject control to your document from the Data Sources window. This method is useful when you want to bind the control to data at the time of creation of the control. You can add the host control in the same way you would add a Windows Form control from the Data Sources window. For more information, see Data Binding and Windows Forms.

  • Programmatically.

    You can add the ListObject control dynamically at run-time. This enables you to create the host controls in response to events. Dynamically created list objects are not persisted in the document as host controls when the document is closed. For more information, see Adding Controls to Office Documents at Run Time.

To add a ListObject control to a worksheet using the Create List dialog box in Excel

  1. From the Data menu, point to Microsoft Office Excel Data Commands, point to List and select Create List.

    The Create List dialog box appears.

    NoteNote

    If Microsoft Office Excel Data Commands is not available in the Data menu, click the document to give it focus.

  2. Select the cell or cells you want to include in the list and click OK.

To add a ListObject control to a worksheet using the Toolbox

  1. Open the Toolbox and click the Excel Controls tab.

  2. Click ListObject and drag it to a worksheet.

    The Add ListObject Control dialog box appears.

  3. Select the cell or cells you want to include in the list and click OK.

    If you do not want the default name given to the control, you can change the name in the Properties window.

You can also programmatically add host controls to a worksheet. In the example below, a ListObject control is added to cells A1 through D4 in the Startup event of Sheet1.

To add a ListObject control to a worksheet programmatically

  • In the Startup event handler of Sheet1, insert the following code to add the ListObject control to cells A1 through A4:

    Microsoft.Office.Tools.Excel.ListObject employeeData;
    employeeData = this.Controls.AddListObject(this.get_Range("$A$1:$D$4", missing), "employees");
    
    

See Also

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2015 Microsoft