Using Visual Studio Tools for Office in Visual Studio 2008
Now, you will see that in Figure 10 you have created a strongly typed dataset named customers; you will use this to refer data from the table into the document. The next step is to create the document panel; that is also made easier using VSTO built into Visual Studio 2008.
Right-click the project in Solution Explorer and then click New item. From the pop up dialog box, select the Actions Pane control from the Office template. Now, you will see a blank area without borders (see Figure 11); this reminds you of creating user controls in .NET. In fact, this is a custom user control on which you can drag and drop controls and write code behind to manipulate data and display the same on the document.
Figure 11: The Actions Pane control resembles the user control in .NET where you can add your own interface.
From the toolbox, drag and drop a BindingSource control on the action control panel. Rename it to CustomersBindingSource.
From the toolbox, drag and drop a Binding Navigator control on the action control panel. Rename it to Navigator1.
Using the properties dialog box, change the Datasource of the CustomersBindingSource control to Party Dataset.
Using the properties dialog box, change the BindingSource of the Navigator1 control to CustomersBindingSource.
Now, drag and drop some labels and text boxes on to the panel so that it looks like Figure 12.
Figure 12: The look of the user control after adding all the controls to view the Customers table.
Now, you need to bind the controls to each column of the table. Select the first text box; in other words, CustomerID. Now, select the Databinding properties from the properties dialog box and then expand it. Select Text from it and on clicking the drop-down arrow, you will see that you are able to see the list of datasources that you created just now. Expand it until you see the columns of the Customers table. See Figure 13. Select the first column CustomerId; this will bind the control to this column.
Figure 13: Mapping each field in the Actions Pane control with each field in the Table Adapter.
Page 5 of 7