Add control dynamically to container in Task Pane

Add-in Express™ Support Service
That's what is more important than anything else

Add control dynamically to container in Task Pane
 
Martin Kirsten




Posts: 71
Joined: 2008-04-23
Hi

I have created an add-in that contains an AddinExpress.MSO.ADXTaskPane. I have added a user control that consists of a System.Windows.Forms.Panel to this task pane. I dynamically try to add a System.Windows.Forms.WebBrowser to the panel in the AddinModule_OnTaskPaneAfterCreate event, but the web browser is not being added.

Any advice will be appreciated.

PS I have read the post at http://www.add-in-express.com/forum/read.php?FID=5&TID=3687&MID=17628&phrase_id=959720, but that only appears to say that you can't load/replace a control in a task pane dynamically, as opposed to adding a control to a container in a task pane (which is what I am trying to do).
Posted 29 Jul, 2008 11:50:54 Top
Eugene Astafiev


Guest


Hi Martin,

Do you develop an add-in for Outlook?

Posted 30 Jul, 2008 07:10:31 Top
Martin Kirsten




Posts: 71
Joined: 2008-04-23
Hi Eugene

Yes, eventually the add-in will also target Outlook, but at the moment only for Word, Excel and PowerPoint 2007. My question above relates to Word, Excel and PowerPoint 2007.
Posted 30 Jul, 2008 07:45:28 Top
Eugene Astafiev


Guest


Hi Martin,

You can place the System.Windows.Forms.WebBrowser control to the UserControl descendant or to another container (in your case it is a panel) dynamically. First, I add the LoadWebBrowser() method to the UserControl descendant where I add the WebBrowser control. I use the following code:


private void AddinModule_OnTaskPaneAfterCreate(object sender, AddinExpress.MSO.ADXTaskPane.ADXCustomTaskPaneInstance instance, object control)
{
     UserControl1 cont = control as UserControl1;
     cont.LoadWebBrowser();
}
Posted 30 Jul, 2008 09:48:22 Top
Martin Kirsten




Posts: 71
Joined: 2008-04-23
Hi Eugene

Thank you, that worked! Strangely, I was doing the same in my existing add-in and it wasn't working, but when I created a new add-in from scratch and used this method, it worked.

Thanks again.
Posted 30 Jul, 2008 13:04:07 Top