2015-11-27 84 views
0

Visual Studio 2015.我可以使用Visual Studio在Microsoft Project中創建CustomTaskPane嗎?

我按照這個簡單的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?

回答

0

很多谷歌搜索後,我找到了答案張貼堆疊交換後沒多久 - 不知道爲什麼,但訪問CustomTaskPanes的方式是不同的MSProject:

UserControl1 uc = new UserControl1(); 

Microsoft.Office.Tools.CustomTaskPaneCollection customPaneCollection; 
customPaneCollection = Globals.Factory.CreateCustomTaskPaneCollection(null, null, "Panes", "Panes", this); 

Microsoft.Office.Tools.CustomTaskPane ctp = customPaneCollection.Add(uc, "Title"); 
ctp.Visible = true; 
相關問題