-->

How do I enable/disable my Ribbon Buttons in Outlo

2019-07-22 12:24发布

问题:

I have an Outlook Add-in created with VSTO. Using the Ribbon Designer I have created a tab with three buttons on it. (Environment: Outlook 2010, .NET 4.0, VSTO latest runtime)

When one of the buttons is pressed a modeless dialog is opened. As long as the user is working on this dialog I do not want him to be able to press the button again. So basically I want to gray out the button till the dialog is closed. How can I do this?

For whatever reason, in the button click handler, if I do this.button1.enabled = false; it is just not working. Am I missing something about the way ribbons work.

Thanks

回答1:

You need to re-render the control using IRibbonUI.InvalidateControl(controlID) or IRibbonUI.Invalidate(). See MDSN on how to dynamically update the Fluent UI for reference. This is done for performance reasons so that you can change all your Fluent UI settings and then re-render all control changes at once. However, if you are only changing one UI element (as you indicate) this can seem confusing and unnecessary.