When you design an actions pane control, it can be helpful to resize the control to the width of the task pane so that you can see exactly what the controls will look like when they are visible on the task pane. The actions pane control can be found in the New Items dialog box.
1. Create a new Excel Workbook solution using VSTO.
2. Right-click your Excel solution in Solution Explorer, point to Add, and then click New Item.
3. In the Add New Item dialog box, click Actions Pane Control, and then click Add. See Figure 5.3, presented earlier, for an example.
4. Expand the Size property for the control and set the width to 200.
You can add Windows Forms controls to the design surface of the actions pane control by dragging the controls from Toolbox.
5. Add two Label controls, and change the second label to resemble a text box by selecting a white background color, adding a border, and changing the AutoSize property to False (see Figure 5.4).
6. Keep the default name of the label (Label1) for the first label on the control, and change its Text property to Formatting of Active Cell.
7. Change the name of the second label to SelectionFont, set the Tex-tAlign property to MiddleCenter, and clear out any text.
You should also change the anchor of each of these controls so that the labels resize if the task pane is resized. Set the Anchor property to Top, Left, Right for each label. The code to add this actions pane control to the action pane should be added to the Startup event handler of ThisWorkbook. The variable to reference the control is created at the class level as a public variable so that you can access it from the worksheet using the Globals class.
8. Add the code in Listing 5.7 to the ThisWorkbook class, replacing the existing Startup event handler.
Listing 5.7. Displaying the actions pane control on the actions pane Public ActionsControl As New ActionsPaneControl1
Private Sub ThisWorkbook_Startup(ByVal sender As Object, _ ByVal e As System.EventArgs) Handles Me.Startup
Was this article helpful?