C# 在CustomTaskPane中单击按钮时如何更改功能区上按钮的标签(Word加载项VSTO)
我已经创建了两个按钮,状态按钮,在我的Word加载项功能区中默认为“打开”,以及在我的自定义任务窗格中创建了更改状态按钮 单击CustomTaskPane上的更改状态按钮时,如何将状态按钮的标签从“打开”更改为“关闭”(在Word加载项功能区上) 此代码功能区:C# 在CustomTaskPane中单击按钮时如何更改功能区上按钮的标签(Word加载项VSTO),c#,vsto,ribbon,word-addins,customtaskpane,C#,Vsto,Ribbon,Word Addins,Customtaskpane,我已经创建了两个按钮,状态按钮,在我的Word加载项功能区中默认为“打开”,以及在我的自定义任务窗格中创建了更改状态按钮 单击CustomTaskPane上的更改状态按钮时,如何将状态按钮的标签从“打开”更改为“关闭”(在Word加载项功能区上) 此代码功能区: using System.Windows.Forms; using Microsoft.Office.Tools.Ribbon; using Office = Microsoft.Office.Core; namespace Test
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=…这是否回答了您的问题?不,我的要求是申请word加载项vsto。非常感谢。多谢各位