gpt4 book ai didi

c# - 将 winform 插件添加到 Word 中的自定义任务 Pane

转载 作者:太空宇宙 更新时间:2023-11-03 10:56:01 29 4
gpt4 key购买 nike

我正在使用 Visual Studio 2010 和 Word 2010

我已经按照本指南在 Word 中创建了一个 Winform 插件 Create addin using VSTO in MS Word

现在我想将此插件停靠到 Word 面板。我听说我可以通过自定义任务 Pane 来做到这一点,我试过了,但不知道怎么做。

有人知道怎么做吗?

非常感谢 :) 我得到了 Pane ,但无法将 winform 添加到其中。最后,我必须将我所有的 winform 控件放入 usercontrol 中,现在它可以工作了。

最佳答案

您应该首先创建一个用户控件(您可以使用设计器来完成),我们将其命名为 CustomUserControl,然后添加以下内容:

private CustomUserControl myUserControl;
private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;

现在,在您的任务 Pane 类或 AddIn_Startup 函数中,添加以下内容:

myUserControl = new CustomUserControl();
myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(myUserControl, "TaskPane Title");

您可以通过更改 Visible 属性来控制任务 Pane 的可见性:myCustomTaskPane.Visible = true;

请注意,在 Word 中创建此类自定义任务 Pane 时,它将与事件文档相关联。根据您要执行的操作,您应该考虑为每个文档创建自己的实例。有关更多信息,请参阅此处: Managing Custom Task Panes in Multiple Application Windows

关于c# - 将 winform 插件添加到 Word 中的自定义任务 Pane ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19491946/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com