簡體   English   中英

單擊 CustomTaskPane 上的按鈕時如何更改功能區上按鈕的標簽(VSTO 中的 Word 添加)

[英]How to change lable of button on Ribbon (Word Add In VSTO) when click button at CustomTaskPane

我創建了兩個按鈕,在我的Word 加載項功能區中使用默認“打開”的狀態按鈕和在我的 CustomTaskPane 中的ChangeStatus按鈕。

單擊CustomTaskPaneChangeStatus按鈕時,如何將狀態按鈕的標簽從“打開”更改為“關閉”(在Word 加載項功能區上)。

圖片

此代碼功能區:

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

        private void btnStatus_Click(object sender, RibbonControlEventArgs e)
        {
            // create new customtaskpane
            myDetail = new Detail();
            myCustomTaskPane = Globals.ThisAddIn.CustomTaskPanes.Add(myDetail, "Error List");
            myCustomTaskPane.DockPosition = Office.MsoCTPDockPosition.msoCTPDockPositionRight;
            myCustomTaskPane.Width = 380;
            myCustomTaskPane.Visible = true;
        }
    }
}

CustomTaskPane 中的此代碼 UserControl:

namespace TestWordAddIn
{
    public partial class Detail : UserControl
    {
        private Word.Application wApp = Globals.ThisAddIn.Application;
        public Detail()
        {
            InitializeComponent();
        }
        private void Detail_Load(object sender, EventArgs e)
        {
        }

        private void btnChangeStatus_Click(object sender, EventArgs e)
        {
            // Change status "Open" button to "Close" button in Ribbon when click ChangeStatus button at CustomTaskPane  
        }
    }
}

此代碼 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
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }

        #endregion
    }
}

像這樣:

Globals.Ribbons.Ribbon1.btn.label =...

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM