Change glyph of ribbon button

Add-in Express™ Support Service
That's what is more important than anything else

Change glyph of ribbon button
 
Subscribe
Mark Wijnbergen




Posts: 20
Joined: 2019-03-18
Hi,

I'm currently trying to change the glyph of a ribbon button during run time.
This ribbon button is part of a RibbonTab.

At first, I tried to update the glyph of the button via:

this.ButtonName.PropertyChanging += new AddinExpress.MSO.ADXRibbonPropertyChanging_EventHandler(this.ButtonName_PropertyChanging);

&&


private void ButtonName_PropertyChanging(object sender, AddinExpress.MSO.ADXRibbonPropertyChangingEventArgs e)
{
  if (e.PropertyType == AddinExpress.MSO.ADXRibbonControlPropertyType.Glyph)
  {
     e.Value = "link to new icon";
  }
}


Here, it was expected that this PropertyChanging event would be called every time the RibbonTab was being selected.
However, I encountered the issue that the first time the RibbonTab was selected, this propertychanging event was called, whereas this propertychanging event is not called on subsequent events when the RibbonTab is selected. This is also the case when I don't include

     e.Value = "link to new icon";

in the code.

I also tried to change the code slightly and base it on the example given in this topic https://www.add-in-express.com/forum/read.php?PAGEN_1=2&FID=5&TID=8931#nav_start. However, the add-in is in Outlook instead of Excel and as such I run into the issue where there is no
OutlookApp.CommandBars
.

Based on the above, I have three questions:

1) When is this PropertyChanging event called?
2) Is there an event within the buttons of a ribbon tab that is called every time the ribbon tab is selected?
3) What is the equivalent of
ExcellApp.CommandBars
that I can use as given in the example of Eugene Astafiev so I can use this code for the OutlookApp?

Best,

Mark
Posted 22 Jul, 2019 07:08:16 Top
Andrei Smolin


Add-in Express team


Posts: 16314
Joined: 2006-05-11
Hello Mark,

Office calls PropertyChanging when it *thinks* it's the best time to do this. To bypass this, you can call the Invalidate() method available on every ADXRibbon* component. You can also set ADXRibbonButton.Glyph directly; the setter of this property calls ADXRibbonButton.Invalidate() for you. When Invalidate is called on a Ribbon component, Office retrieves all properties required to display the corresponding control; if you do not handle PropertyChanging(), Add-in Express provides the values for you.

See also section Updating Ribbon Controls at Run Time, see the PDF file in the folder {Add-in Express}\Docs on your development PC.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jul, 2019 08:08:41 Top
Mark Wijnbergen




Posts: 20
Joined: 2019-03-18
Hi Andrei,

Thanks very much, this is working indeed.

Best wishes,

Mark
Posted 22 Jul, 2019 09:15:46 Top
Andrei Smolin


Add-in Express team


Posts: 16314
Joined: 2006-05-11
Welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 22 Jul, 2019 09:28:08 Top