0

I'm creating a CustomTaskPane for a Word plugin, and putting some third party controls on the control that's on the CustomTaskPane. However, those controls are expecting to be part of a .net Form, and call FindForm() on themselves, which traverses the Control.Parent tree up until it hits a Form.

However, the CustomTaskPane control never gets a parent, and isn't on a .Net form. I'm using the same code I've seen on Microsoft's website and elsewhere to add my CustomTaskPane (C#):

MyControl ctrl = new MyControl; Microsoft.Office.Tools.CustomTaskPane pane = Globals.ThisAddIn.CustomTaskPanes.Add(ctrl, "Custom Pane");

At this point, ctrl.Parent is null.... and I can't find a valid control to set as the parent. I'm running as a plugin, so I don't have a reference to a form, all the objects available are COM objects from the Office Object Model.

Thoughts?

Nate Finch
  • 253
  • 3
  • 13
  • So, I never did figure it out, but I replaced the controls with others that don't have the same restriction. We wanted to deprecate those particular controls anyway. – Nate Finch Mar 23 '11 at 01:03

1 Answers1

0

Answer for others with this issue (as you've solved it). We always create a UserControl that we set to fill the task pane. We then put all controls in the UserControl.

David Thielen
  • 28,723
  • 34
  • 119
  • 193
  • That doesn't really solve the problem. I was putting a UserControl on the taskpane too. The problem is that the third party controls were looking for a _Form_ specifically, which a UserControl is not. I guess that's just poor coding on the part of the third party controls. – Nate Finch Oct 12 '11 at 15:47
  • Ow - yes. Never require that unless the 3rd party control can only perform that operation on a Form. – David Thielen Oct 16 '11 at 01:03