Reputation: 51
I have a project in which I'm using the Office.IRibbonExtensibility inheritance. The issue I'm having is that my project requires me to 'uncheck' a checkbox when a button is pressed on the ribbon. As far as I can tell, only your currently selected control is accessible in code through the Office.IRibbonControl property of the button press handler. So my question is, how do I access my checkbox element in the button click event in an XML based VSTO project?
Upvotes: 2
Views: 840
Reputation: 3565
Try this code
Ribbon.xml
<?xml version="1.0" encoding="UTF-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab idMso="TabAddIns">
<group id="group1" label="group1">
<button id ="btnTest" size="large" label="TestButton" onAction="btnTest_Click"/>
<checkBox id ="chkTest" label="TestCheckbox" getPressed="chkTest_pressed" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
Ribbon.cs
private bool isChecked = false;
public void btnTest_Click(IRibbonControl ribbon)
{
isChecked = true;
this.ribbon.Invalidate();
}
public bool chkTest_pressed(IRibbonControl ribbon)
{
return isChecked;
}
Upvotes: 1