Mark Wijnbergen
Posts: 27
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 |
|
Andrei Smolin
Add-in Express team
Posts: 18787
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.
Andrei Smolin
Add-in Express Team Leader |
|
Mark Wijnbergen
Posts: 27
Joined: 2019-03-18
|
Hi Andrei,
Thanks very much, this is working indeed.
Best wishes,
Mark |
|
Andrei Smolin
Add-in Express team
Posts: 18787
Joined: 2006-05-11
|
Welcome!
Andrei Smolin
Add-in Express Team Leader |
|