对于out外接程序,使用以下代码将新的自定义任务窗格添加到特定窗口:
historyPane = new HistoryPane(taskId);
customTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(historyPane, title, new Microsoft.Office.Interop.Outlook.Application().ActiveWindow());现在我想为特定的窗口再次关闭这个customTaskpane,我已经到处寻找了,不幸的是没有任何成功。
我在活动窗口中找不到任务窗格。我试着为一个窗口或一些东西寻找一些唯一的ID,以链接到字典并以这种方式关闭它,但也没有任何运气。
有没有人能帮我或者给我指个好方向?
发布于 2017-04-16 02:12:58
您可以使用CustomTaskPanes类的Remove或RemoveAt方法。
public void RemoveTaskPaneWithTitle()
{
for (int i = this.CustomTaskPanes.Count; i > 0; i--)
{
ctp = this.CustomTaskPanes[i - 1];
if (ctp.Title == "Your title")
{
this.CustomTaskPanes.RemoveAt(i - 1);
}
}
}此外,您还可以考虑使用Visible属性隐藏窗格。
在Managing Task Panes in Multiple Word and InfoPath Documents文章中阅读有关可能的选项的更多信息。
https://stackoverflow.com/questions/43409569
复制相似问题