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 u开发者_如何学Gop 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?
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.
精彩评论