Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
 How to: Add a Custom Task Pane to a...
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Microsoft Visual Studio Tools for the Microsoft Office system (version 3.0)
How to: Add a Custom Task Pane to an Application

Applies to

The information in this topic applies only to the specified Visual Studio Tools for Office projects and Microsoft Office applications.

Project type

  • Application-level projects

Microsoft Office application

  • Excel 2007

  • InfoPath 2007

  • Outlook 2007

  • PowerPoint 2007

  • Word 2007

For more information, see Features Available by Application and Project Type.

You can add a custom task pane to the applications listed above by using an application-level add-in. For more information, see Custom Task Panes Overview.

NoteNote:

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To add a custom task pane to an application

  1. Open or create an application-level project for one of the applications listed above in the 2007 Microsoft Office system. For more information, see How to: Create Visual Studio Tools for Office Projects.

  2. On the Project menu, click Add User Control.

  3. In the Add New Item dialog box, change the name of the new user control to MyUserControl, and then click Add.

    The user control opens in the designer.

  4. Add one or more Windows Forms controls from the Toolbox to the user control.

  5. Open the ThisAddIn.cs or ThisAddIn.vb code file.

  6. Add the following code to the ThisAddIn class. This code declares instances of MyUserControl and CustomTaskPane as members of the ThisAddIn class.

    Visual Basic
    Private myUserControl1 As MyUserControl
    Private myCustomTaskPane As Microsoft.Office.Tools.CustomTaskPane
    
    C#
    private MyUserControl myUserControl1;
    private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
    
  7. Add the following code to the ThisAddIn_Startup event handler. This code creates a new CustomTaskPane by adding the MyUserControl object to the CustomTaskPanes collection. The code also displays the task pane.

    Visual Basic
    myUserControl1 = New MyUserControl
    myCustomTaskPane = Me.CustomTaskPanes.Add(myUserControl1, "My Task Pane")
    myCustomTaskPane.Visible = True
    
    C#
    myUserControl1 = new MyUserControl();
    myCustomTaskPane = this.CustomTaskPanes.Add(myUserControl1, "My Task Pane");
    myCustomTaskPane.Visible = true;
    
    NoteNote:

    This code associates your custom task pane with the active window in the application. For some applications, you might want to modify this code to ensure that the task pane appears with other documents or items in the application. For more information, see Managing Custom Task Panes in Multiple Application Windows.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker