Scenario/Problem: | You want to create a custom task pane. |
Solution: | Use Visual Studio 2010 to create a new InfoPath add-in. |
To create a new task pane, follow the steps for creating a new InfoPath 2010 add-in. Then perform these steps:
1. | Add a user control to your project.
|
2. | Add windows controls to your user control as needed. In this example, a user control named CustomTaskPaneControl is used.
|
3. | Add any code to handle options or selections.
|
4. | In the ThisAddIn class, add private variables to handle the user control and custom task pane, as shown in Listing 1.
|
5. | In the startup method of the ThisAddIn class, add code to instantiate the user control as a custom task pane, as shown in Listing 2.
Listing 1. Private Declarations
private CustomTaskPaneControl customTaskPaneControl; private Microsoft.Office.Tools.CustomTaskPane customTaskPane;
|
Listing . Custom Task Pane Instantiation
customTaskPaneControl = new CustomTaskPaneControl(); customTaskPane = this.CustomTaskPanes.Add(customTaskPaneControl, "Custom Task Pane"); customTaskPane.Visible = true;
|
|
6. | Build the project, and then launch InfoPath Designer 2010. The custom task pane appears as shown in Figure 1.
|