2

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

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

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

在此处输入图像描述

演示.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
    }
}
4

0 回答 0