如何在 Outlook 中启用/禁用功能区按钮
我有一个使用 VSTO 创建的 Outlook 加载项。我使用功能区设计器创建了一个带有三个按钮的选项卡。 (环境:Outlook 2010、.NET 4.0、VSTO 最新运行时)
按下其中一个按钮时,将打开一个无模式对话框。只要用户正在处理此对话框,我就不希望他能够再次按下该按钮。所以基本上我想让按钮变灰,直到对话框关闭。我该怎么做?
无论出于何种原因,在按钮单击处理程序中,如果我这样做 this.button1.enabled = false;
它就不起作用。我是否错过了丝带工作方式的一些内容?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用
IRibbonUI.InvalidateControl(controlID)
或IRibbonUI.Invalidate()
重新呈现控件。请参阅 MDSN,了解如何动态更新 Fluent UI 以供参考。这样做是出于性能原因,以便您可以更改所有 Fluent UI 设置,然后立即重新渲染所有控件更改。但是,如果您仅更改一个 UI 元素(如您所指示的),这可能会显得令人困惑且不必要。You need to re-render the control using
IRibbonUI.InvalidateControl(controlID)
orIRibbonUI.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.