首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我可以使用Visual在Microsoft中创建CustomTaskPane吗?

我可以使用Visual在Microsoft中创建CustomTaskPane吗?
EN

Stack Overflow用户
提问于 2015-11-27 12:26:52
回答 1查看 383关注 0票数 0

Visual Studio 2015。

我遵循这个简短的教程在Word中创建了一个CustomTaskPane。我已经设法让它起作用了。我也想为Microsoft做同样的事情,但我遇到了第一个障碍:

代码语言:javascript
复制
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
    }
}

上面的方法适用于一个单词AddIn,但是当我试图为一个项目AddIn执行它时,我会得到以下错误:

严重性代码描述项目文件行错误名称‘D:\DevProjects\MSProjectAddIn1\MSProjectAddIn1\ThisAddIn.cs’在当前上下文MSProjectAddIn1 17中不存在

代码语言:javascript
复制
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
    }
}

有人为CustomTaskPane创建了MSProject吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-11-27 14:46:12

经过大量的谷歌搜索,我在发布到堆栈交换后不久就找到了一个答案--不知道为什么,但访问CustomTaskPanes的方式在MSProject中是不同的:

代码语言:javascript
复制
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;
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33957427

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档