获取 Outlook 后台的复选框状态?
使用 Outlook 2010:如果我在 XML 中定义了一个复选框供后台加载,我如何查询该元素并使用 C# 获取其状态?下面是后台 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="MyBackstageTab_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>
...这是 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);
}
}
}
我的想法是在 MyRibbon
类中记录每个元素的状态,就像事件一样当用户与表单交互时触发。但是,由于有些东西(例如上面示例中的复选框)似乎不会触发任何可用的事件,因此我需要一些其他方法来从此类中查询后台。
因此,如果我有一个Apply按钮将表单状态保存在某处(代表加载项设置):我可以对单击该按钮做出反应,但如何才能获得复选框
那时的状态?
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="MyBackstageTab_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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查这个答案:如何访问后台Office 插件中的复选框值?
ps:我在写完我的问题后发现了您的问题 :)
Check this answer: How to access backstage checkbox value in an Office addin?
ps: I found your question after writing mine :)