2011-01-14 127 views
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_load_finish_method?

我使用VisualStudio 2010和.Net 3.5

感謝您的時間!

回答

0

爲什麼要通過所有rigamarole?我不得不寫一些類似的東西(對於一個郵件項目,而不是預約),它需要一個基於註冊表項設置的按鈕。這是我的方法。我並不是說這是完美的,但它對我有用。

下面是從我(馬虎)代碼片段:

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 
    }