为什么更改VSTO中单词添加时功能区中的File2状态​​和File1也会更改

问题描述

我已经在我的Word加载项功能区中创建了两个按钮:状态按钮和默认的“打开”按钮和 ChangeStatus 按钮。

我打开两个文件进行测试。我单击 ChangeStatus 按钮,将file2更改为“关闭”,file1也更改为“关闭”。

当我单击文件2上的 ChangeStatus 按钮时,如何强制文件1显示“打开而不关闭”。 (只有状态按钮file2更改为“关闭”)

image 1

Demo.cs:

using System.Windows.Forms;
using Microsoft.Office.Tools.Ribbon;
using Office = Microsoft.Office.Core;
namespace TestWordAddIn
{
    public partial class Demo
    {
        private Responsive responsive;
        private Detail myDetail;
        private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
        private void Demo_Load(object sender,RibbonUIEventArgs e)
        {
            responsive = new Responsive(Screen.PrimaryScreen.Bounds);
            responsive.SetMultiplicationFactor();
        }

        private void btnStatus_Click(object sender,RibbonControlEventArgs e)
        {
            myDetail = new Detail();

            myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(myDetail,"Error List");
            myCustomTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
            myCustomTaskPane.Width = responsive.GetMetrics(380);
            myCustomTaskPane.Visible = true;
        }

        private void btnChangeLable_Click(object sender,RibbonControlEventArgs e)
        {
            btnStatus.Label = "Close";
        }
    }
}

此代码ThisAddIn.css:

namespace TestWordAddIn
{
    public partial class ThisAddIn
    {
    
        private void ThisAddIn_Startup(object sender,System.EventArgs e)
        {
        
        }

        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
    }
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...