加载色带时更改色带中的按钮

发布于 2024-10-12 05:24:57 字数 726 浏览 7 评论 0原文

我为 Outlook 2007 AppointmentItem 创建了一个自定义功能区。 AppointmentItem 可以具有自定义属性。设置自定义属性后,应禁用自定义功能区中的按钮(默认情况下启用)。

我在自定义功能区中尝试了 _Load 函数,但该按钮仍然处于启用状态。我可以调试它:字符串已填充并且按钮将被禁用,但在前端没有任何反应。

public partial class Ribbon1 {  
[...]  
    private void Ribbon1_Load(object sender, RibbonUIEventArgs e)  
    {  
        if (myCustomProperty != "")  
        {  
            Globals.Ribbons[Globals.ThisAddIn.Application.ActiveInspector()]  
                .Ribbon1.buttonCollaborate.Enabled = false;  
        }  
    }  
    [...]  
}  

我不知道出了什么问题,可能是 Globals.Ribbons[...].Ribbon1 不是当前的 Ribbon?或者有ribbon_load_finish_method吗?

我使用了 VisualStudio 2010 和 .Net 3.5

感谢您的宝贵时间!

I created a custom Ribbon for an Outlook 2007 AppointmentItem. The AppointmentItem can have a custom property. When the custom property is set, a button in the custom Ribbon should be disabled (by default it is enabled).

I tried the _Load function in my custom Ribbon, but the button is still enabled. I can debug it: the string is filled and the button will be disabled, but in the frontend nothing happens.

public partial class Ribbon1 {  
[...]  
    private void Ribbon1_Load(object sender, RibbonUIEventArgs e)  
    {  
        if (myCustomProperty != "")  
        {  
            Globals.Ribbons[Globals.ThisAddIn.Application.ActiveInspector()]  
                .Ribbon1.buttonCollaborate.Enabled = false;  
        }  
    }  
    [...]  
}  

I don't know whats wrong, may be Globals.Ribbons[...].Ribbon1 is not the current Ribbon? Or is there a ribbon_load_finish_method?

I used VisualStudio 2010 and .Net 3.5

Thanks for your time!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

感情旳空白 2024-10-19 05:24:57

为什么要经历所有这些繁琐的事情?不久前我不得不写一些类似的东西(对于邮件项目,而不是约会),需要根据注册表项设置一个按钮。这就是我的方法。我并不是说它是完美的,但它对我有用。

这是我的(草率的)代码的片段:

string taglineActive;
OLRegistryAddin buttonSet = new OLRegistryAddin();  // variable for reading the value of the registry key
UpdateBody msgBody = new UpdateBody();  // method for adding/removing tagline from the message

private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
    taglineActive = buttonSet.RegCurrentValue();  // retrieve the current registry value

    if (taglineActive == "0")
    {
        // tagline is off for all messages
        ActiveAllMessages.Checked = false; // uncheck "All Messages" button
        ActiveAllMessages.Label = "Inactive - All Messages";  // change the label
        ActiveThisMessage.Visible = false;  // hide the "This Message" button
        ActiveThisMessage.Enabled = false;  // deactivate the "This Message" button
    }
    else if (taglineActive == "1")
    {
        // tagline is on for all messages
        ActiveAllMessages.Checked = true;   // check "All Messages" button
        ActiveAllMessages.Label = "Active - All Messages";  // change the label
        ActiveThisMessage.Visible = true;   // show the "This Message" button
        ActiveThisMessage.Enabled = true;   // activate the "This Message" button
    }

Why go through all the rigamarole? I had to write something similar a while back (for a mail item, not appointment) that required a button to be set based on a registry entry. This was my approach. I'm not saying it's perfect, but it worked for me.

Here's a snippet from my (sloppy) code:

string taglineActive;
OLRegistryAddin buttonSet = new OLRegistryAddin();  // variable for reading the value of the registry key
UpdateBody msgBody = new UpdateBody();  // method for adding/removing tagline from the message

private void Ribbon1_Load(object sender, RibbonUIEventArgs e)
{
    taglineActive = buttonSet.RegCurrentValue();  // retrieve the current registry value

    if (taglineActive == "0")
    {
        // tagline is off for all messages
        ActiveAllMessages.Checked = false; // uncheck "All Messages" button
        ActiveAllMessages.Label = "Inactive - All Messages";  // change the label
        ActiveThisMessage.Visible = false;  // hide the "This Message" button
        ActiveThisMessage.Enabled = false;  // deactivate the "This Message" button
    }
    else if (taglineActive == "1")
    {
        // tagline is on for all messages
        ActiveAllMessages.Checked = true;   // check "All Messages" button
        ActiveAllMessages.Label = "Active - All Messages";  // change the label
        ActiveThisMessage.Visible = true;   // show the "This Message" button
        ActiveThisMessage.Enabled = true;   // activate the "This Message" button
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文