在运行时向 RibbonDropDown 添加项目 [英] Adding items to RibbonDropDown at runtime

查看:36
本文介绍了在运行时向 RibbonDropDown 添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在功能区中有一个下拉菜单,其中的内容可以在使用时更改.Outlook 也很乐意让我向其中添加"或插入"项目,只要我添加的项目不超过 1 个.

So I have a dropdown menu in a ribbon with contents that can be changed while it is being used. Outlook is also happy to let me 'add' or 'insert' items into it, as long as I do not add more than 1 item.

如果我尝试这样做,我会被告知索引超出范围,而不是为我扩大上限.

If I try to, I'll be told that the index is out of bounds rather than expanding the upper bounds for me.

我发现如果我将它插入到代码的设计器部分的集合中,它会正常工作,但设计器代码只运行一次,除非我处理功能区并重新创建它.

I find that if I insert it into the collection in the designer portion of the code, it will work fine, but designer code is only run once, unless I Dispose the ribbon and re-create it.

关于我如何让这个工作的任何想法

Any ideas regarding how I can get this working

推荐答案

一般来说,VSTO 希望你一次完整地描述你需要的 UI 元素,在你第一次被要求时(通过 GetCustomUI).

Generally speaking, VSTO wants you to completely describe the UI elements you need one time, the very first time you're asked for them (via GetCustomUI).

我之前在使用 vsto 时遇到过类似的问题,我发现唯一合理的方法是预先填充(通过设计器)您可能需要的所有元素(假设下拉列表中有 10 个项目)).

I've run into similar probs before with vsto and about the only reasonable way around it I've found was to prepopulate (via the designer) all the elements you might need (so let's say 10 items in your drop down list).

然后,以编程方式隐藏或显示这些项目,并在您的插件运行时根据需要更新它们的标题和其他属性.

Then, programmatically HIDE or SHOW those items and update their captions and other properties as necessary while your addin runs.

这样,您就不必动态添加或删除任何内容.

That way, you never have to dynamically add or remove anything.

这篇关于在运行时向 RibbonDropDown 添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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