开发者

Get checkbox status on Outlook Backstage?

With Outlook 2010: if I have a checkbox defined in XML for the backstage to load, how can I query that element and get its status with C#? Here's an example of the backstage XML:

<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="Ribbon_Load"
          xmlns="http://schemas.microsoft.com/office/2009/07/customui">
  <backstage>
    <tab id="MyBackstageTab"
         getVisible="MyBackstageTa开发者_StackOverflow社区b_GetVisible">
      <firstColumn>
        <group id="RegularGroup">
          <bottomItems>
            <groupBox id="GeneralGroupBox">

              <!-- This works fine; onAction is called every click. -->
              <button id="ApplyButton"
                      label="Apply"
                      onAction="ButtonAction"/>

              <!-- Neither onAction or getPressed functions are called
                   when interacting with the checkbox on the form. -->
              <checkBox id="AddInEnabled"
                        label="Enable AddIn"
                        onAction="CheckBoxAction"
                        getPressed="CheckBoxPressed"/>

            </groupBox>
          </bottomItems>
        </group>
      </firstColumn>
    </tab>
  </backstage>
</customUI>

...and here's the MyRibbon.cs:

namespace MyAddIn {

    [ComVisible(true)]
    public class MyRibbon : Office.IRibbonExtensibility {

        // constructors, etc...

        public void ButtonAction(Office.IRibbonControl control) {
            System.Windows.Forms.MessageBox.Show(
                "ButtonAction: " + control.Id);
        }

        // Never gets called.
        public void CheckBoxAction(Office.IRibbonControl control) {
            System.Windows.Forms.MessageBox.Show(
                "CheckBoxAction: " + control.Id);
        }

        // Never gets called.
        public void CheckBoxPressed(Office.IRibbonControl control) {
            System.Windows.Forms.MessageBox.Show(
                "CheckBoxPressed: " + control.Id);
        }

    }
}

My thinking is to record each elements' status, inside the MyRibbon class, as events are fired when the user interacts with the form. However, since some things (like the checkbox in my example above) don't seem to trigger any usable events, I need some other way to query the backstage from within this class.

So if I have an Apply button that will save the form state somewhere (representing AddIn settings): I can react to that button being clicked, but how can I also get the checkbox state at that point?


Check this answer: How to access backstage checkbox value in an Office addin?

ps: I found your question after writing mine :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜