Solved

VB.net Embed Windows form in a Custom Task Pane

Posted on 2012-04-05
13
684 Views
Last Modified: 2012-06-27
Hi

Is it possible to embed  a Windows form in a Custom Task Pane?
0
Comment
Question by:murbro
  • 5
  • 4
  • 2
  • +1
13 Comments
 
LVL 17

Expert Comment

by:nepaluz
ID: 37814379
Me.Form2.Parent = MyCustomTaskPane
0
 
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)
0
 
LVL 85

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.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 

Author Comment

by:murbro
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:
http://msdn.microsoft.com/en-us/library/bb608590.aspx
0
 
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.
0
 

Author Comment

by:murbro
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........
0
 
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.
0
 

Author Comment

by:murbro
ID: 37816864
Thanks for the clarification. Much appreciated
0
 
LVL 85

Accepted Solution

by:
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:
http://msdn.microsoft.com/en-us/library/aa942861.aspx

Also, see "Custom Task Panes Overview":
http://msdn.microsoft.com/en-us/library/aa942864.aspx

    "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."
0
 
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.
0
 

Author Comment

by:murbro
ID: 37818592
Hi. I have requested that question be reopened. Perhaps some light could be shed on a similar sort of question
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_27664118.html#a37818578

Thanks
0
 

Author Closing Comment

by:murbro
ID: 37840174
thanks
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 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