I've create two buttons, Status button with default "Open" in my Word add-in Ribbon and ChangeStatus button at my CustomTaskPane.
How to change lable of Status button from "Open" to "Close" (on Word add-in Ribbon) when click ChangeStatus button at CustomTaskPane.
This code Ribbon:
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;
}
}
}
This code UserControl in CustomTaskPane:
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
}
}
}
This code 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
}
}
Like so:
Globals.Ribbons.Ribbon1.btn.label = ...