Solved

VB.net Embed Windows form in a Custom Task Pane

Posted on 2012-04-05
13
665 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
Comment Utility
Me.Form2.Parent = MyCustomTaskPane
0
 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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
Comment Utility
*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
 

Author Comment

by:murbro
Comment Utility
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

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 40

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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
Comment Utility
Thanks for the clarification. Much appreciated
0
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
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

Expert Comment

by:Jacques Bourgeois (James Burger)
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

743 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now