Solved Embed Windows form in a Custom Task Pane

Posted on 2012-04-05
Last Modified: 2012-06-27

Is it possible to embed  a Windows form in a Custom Task Pane?
Question by:murbro
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
LVL 17

Expert Comment

ID: 37814379
Me.Form2.Parent = MyCustomTaskPane
LVL 40
ID: 37814444
Although many thinks the contrary, a Form is actually a Control. You can use a Form anywhere you use a Control (I often use Forms inside of TabControls), that is in any ContainerControl, the same way you would use a Control into it, such as the following. So, if your custom control inherits from ContainerControl or from any control that inherits from ContainerControl, you can to the following:

YourControl.Controls.Add (New yourForm)
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 37814525
*For a FORM, you need to set TopLevel() to False before you can add it to a container.  This must be done at run-time.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 37815218
Hi. I am not sure where to put the code. I have used the example shown at the following link for my TaskPane. How would I embed Form2 inside this:
LVL 40
ID: 37816235
Oh! An Outlook TaskPane. That is something else. You should have told us so. These little details are important when you ask a question.

Outlook is a COM application. It does not use .NET controls, but ActiveX controls that uses other standards.

Microsoft designed Visual Studio .NET to let you write code that can work with ActiveX controls, but you cannot insert .NET controls (a Form is a .NET control as explained before) inside of an ActiveX (Outlook, Word, Excel and many others) application.

Author Comment

ID: 37816566
Its an Excel TaskPane, I think that article is aimed at Excel and Outlook: "Applies to: The information in this topic applies to application-level projects for the following applications: Excel 2007 and Excel 2010; InfoPath 2007 and InfoPath 2010; Outlook 2007........
LVL 40
ID: 37816834
If you go to the article and look at the left pane, you see that it is under the Office UI Customization.

You can use .NET code to manipulate Office, but you cannot use .NET controls for the Office interface because none of the Office applications are .NET, they are all COM applications.

When the article talks about addind controls to the TaskPane, they are from the Office Ribbon Controls, which are not the same type of controls the ones in then Windows.Forms namespace in which the Form is defined.

What you want to do is thus impossible. It like asking to put a Ford motor in a horse. The horse came before the car, so you cannot put a motor inside a horse. You could put a horse inside of a truck however. Same thing here. .NET can work with COM (Office), but not the reverse.

Author Comment

ID: 37816864
Thanks for the clarification. Much appreciated
LVL 86

Accepted Solution

Mike Tomlinson earned 500 total points
ID: 37816898
I'm definitely not an Office developer, but following the links it appears to me that you can develop a .Net UserControl that can then be embedded in an Office Custom Task Pane:

Also, see "Custom Task Panes Overview":

    "Windows Forms Support - The user interface of a custom task pane that you create by using the Office development tools in Visual Studio is based on Windows Forms controls. You can use the familiar Windows Forms Designer to design the user interface for a custom task pane. You can also use the data binding support in Windows Forms to bind a data source to controls on the task pane."

    "Creating the User Interface - All custom task panes that are created by using the Office development tools in Visual Studio contain a UserControl object. This user control provides the user interface of your custom task pane. You can create the user control at design time or at run time. If you create the user control at design time, you can use the Windows Forms Designer to construct the user interface of your task pane."
LVL 40
ID: 37817766
Reading the documentation in the links provided by Idle_Mind seem to point to the fact that I was wrong.

It looks as if they did something special for the CustomTaskPane that did not exist when I did .NET development with Office 2003, where only the TaskPaneControl (not the CustomTaskPane) was available.

I never saw anywhere that you could include a .NET control in a COM application, and I have searched often for that possibility. My hunch is that the CustomTaskPane is not integrated into the Officce application. It might hover over the Office application and "follow" the standard TaskPaneControl through low-level hooks to the Office application, a technique similar to the one that is often used to enhance a grid with a type of cell that it does not provide.

A UserControl is a small Form missing a few features such as the title bar and the control buttons. What you wanted to do with a Form should be possible with a UserControl. And according to Idle_Mind references, this is the way to work with the CustomTaskPane.

You should transfer the points to Idle_Mind if there is a way to do so.

Author Comment

ID: 37818592
Hi. I have requested that question be reopened. Perhaps some light could be shed on a similar sort of question


Author Closing Comment

ID: 37840174

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question