【问题标题】:Change Button in Ribbon on Ribbon load在功能区加载时更改功能区中的按钮
【发布时间】:2011-01-14 16:21:14
【问题描述】:

我为 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

感谢您的宝贵时间!

【问题讨论】:

    标签: c# outlook vsto outlook-addin outlook-2007


    【解决方案1】:

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

    这是我(草率)代码中的一个 sn-p:

    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
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多