Change button "Label" on click Event

Jul 27, 2012 at 10:03 AM
Edited Jul 27, 2012 at 10:07 AM

Hi Guys,

Just Start working with Excel-DNA.

Now i need to change the Label/Text of a ribbon button on the click event.


I've tried define in xml : 


onAction="myToggleButton" getLabel="GetLabel"


and the method's (in the end):

In first Load of Excel, the label is defined correct, but after click event , no changes.

I See this Discussion -> and i understand i need invalidate the control, to unsure that it update, but i can't find a way to get a handle to the ribbonUI.



      private bool _tbstate = false;
        public string GetLabel(IRibbonControl control)
            if (_tbstate == true)
                return "Ocultar Congeladas";
                return "Mostrar Congeladas";

        public void myToggleButton(IRibbonControl control, bool state)
            _tbstate = state;
Jul 27, 2012 at 2:37 PM
Edited Jul 27, 2012 at 2:38 PM

Hi Diogo,

I think you need to add an onLoad handler (both a method and an onLoad="myOnLoadHandler" in the ribbon xml). Then in the onLoad handler you will get the IRibbonUI which you use later to call Invalidate.


Jul 27, 2012 at 4:18 PM

Hi Govert,

Work's Fine with your sugestion

Thank you and Congratulations for your project