如何在功能区(C#)上的现有选项卡上添加按钮? [英] How to add a button to a pre-existing tab on ribbon (C#)?

查看:319
本文介绍了如何在功能区(C#)上的现有选项卡上添加按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功创建了一个新标签,并将其放在现有标签的旁边.然后我意识到我只有一个按钮,所以(现在)将它放在主页"选项卡上更有意义.并没有真正使它起作用.

I've successfully created a new tab and put it next to the pre-existing ones. Then I realized that I'll only have one button on it, so it makes more sense (for now) to put it on the Home tab. Didn't really get that to work though.

我尝试遵循指南和步行槽.我已经有了一个XML,并将其XML更改为以下内容.

I've tried to follow the guides and walk-troughs. I've got me an XML and changed its XML to the following.

<tabs>
  <!--<tab idMso="TabAddIns">-->
  <tab idMso="TabHome">
    <group id="group1" label="Hazaa!">
      <box id="box1" />
    </group>
  </tab>
</tabs>

当我运行项目时,我没有对UI进行任何更改,所以我猜是这样的:

When I run the project I get no changes to the UI, so I guess that either:

  1. 根本不读取XML
  2. 名称TabHome是错误的(至少对于Outlook 2010),
  3. 属性idMso是错误的(至少对于Outlook 2010)或
  4. 任何提及的其他/组合.
  1. the XML is not read at all,
  2. the name TabHome is wrong (at least for Outlook 2010),
  3. the attribute idMso is wrong (at least for Outlook 2010) or
  4. other/combination of any of the mentioned.

我该怎么做才能更改色带? (Outlook 2010/VSTO/VS 2010/.NET 4).

What can I do to alter the ribbon? (Outlook 2010/VSTO/VS 2010/.NET 4).

推荐答案

属性idMso是正确的,但是所需选项卡的ID是TabMail.您可以找到包含Office 2010控件ID列表的打包的Excel文件集在MSDN上.然后,如对该问题的评论中所述,您的示例XML可能缺少customUI和功能区标签. (免责声明:我没有自定义Outlook中的功能区,只有Word,Excel和PowerPoint,但我想它们的功能相同吗?)

The attribute idMso is correct, but the id for the tab you want is TabMail. You can find a packed set of Excel-files containing lists of Office 2010 control IDs on MSDN. Then, as mentioned in a comment to the question, your sample XML may be missing the customUI and ribbon-tags. (Disclaimer: I haven't customized the ribbon in Outlook, only Word, Excel and PowerPoint, but I would guess they work the same?)

尝试这样的事情:

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
    <ribbon>
        <tabs>
            <tab idMso="TabMail">
                <group id="group1" label="Hazaa!">
                    <box id="box1" />
                </group>
            </tab>
        </tabs>
    </ribbon>
</customUI>

这篇关于如何在功能区(C#)上的现有选项卡上添加按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆