【发布时间】:2015-11-27 12:26:52
【问题描述】:
Visual Studio 2015。
我已经按照这个简短的tutorial 在 Word 中创建了一个 CustomTaskPane。我已经设法让它工作了。我想为 Microsoft Project 做同样的事情,但我遇到了第一个障碍:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Word = Microsoft.Office.Interop.Word;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Word;
namespace WordAddIn1
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
UserControl1 uc = new UserControl1();
Microsoft.Office.Tools.CustomTaskPane ctp = CustomTaskPanes.Add(uc, "Title");
ctp.Visible = true;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
以上内容适用于 Word 插件,但当我尝试为项目插件执行此操作时出现以下错误:
严重性代码描述项目文件行 错误 CS0103 当前上下文中不存在名称“CustomTaskPanes” MSProjectAddIn1 D:\DevProjects\MSProjectAddIn1\MSProjectAddIn1\ThisAddIn.cs 17
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using MSProject = Microsoft.Office.Interop.MSProject;
using Office = Microsoft.Office.Core;
namespace MSProjectAddIn1
{
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
UserControl1 uc = new UserControl1();
Microsoft.Office.Tools.CustomTaskPane ctp = CustomTaskPanes.Add(uc, "Title");
ctp.Visible = true;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
}
有人为 MSProject 创建了 CustomTaskPane 吗?
【问题讨论】:
标签: c# visual-studio ms-project office-addins