
Adding Controls to the Worksheet
In this step, you will add a named range, a list object, and two buttons to the first worksheet. First, add the named range and the list object from the Data Sources window so that they are automatically bound to the data source. Next, add the buttons from the Toolbox.
To add a named range and a list object
Verify that the My Master-Detail.xls workbook is open in the Visual Studio designer, with Sheet1 displayed.
Open the Data Sources window and expand the Orders node.
Select the OrderID column, and then click the drop-down arrow that appears.
Click NamedRange in the drop-down list, and then drag the OrderID column to cell A2.
A NamedRange control named OrderIDNamedRange is created in cell A2. At the same time, a BindingSource named OrdersBindingSource, a table adapter, and a DataSet instance are added to the project. The control is bound to the BindingSource, which in turn is bound to the DataSet instance.
Scroll down past the columns that are under the Orders table. At the bottom of the list is the Order Details table; it is here because it is a child of the Orders table. Select this Order Details table, not the one that is at the same level as the Orders table, and then click the drop-down arrow that appears.
Click ListObject in the drop-down list, and then drag the Order Details table to cell A6.
A ListObject control named Order_DetailsListObject is created in cell A6, and bound to the BindingSource.
To add two buttons
From the Common Controls tab of the Toolbox, add a Button control to cell A3 of the worksheet.
This button is named Button1.
Add another Button control to cell B3 of the worksheet.
This button is named Button2.
Next, mark the dataset to be cached in the document.