【问题标题】:Is it possible to add an edit box or combo box to CommandBar["Text"] in Word?是否可以在 Word 中向 CommandBar["Text"] 添加编辑框或组合框?
【发布时间】:2011-04-22 23:34:51
【问题描述】:

我正在尝试在加载 Word 加载项时将编辑框或组合框添加到上下文菜单之一。但我没有成功,也没有出现任何错误,编辑/组合框只是没有出现。

this.Application.CommandBars["Text"].Reset();

// add a menu to the context menu
CommandBarPopup subMenu = (CommandBarPopup)this.Application.CommandBars["Text"].Controls
  .Add(Office.MsoControlType.msoControlPopup, missing, missing, 1, true);

subMenu.Caption = "My menu";

// add combo box to the newly created menu
CommandBarComboBox ctrl = (CommandBarComboBox)subMenu.Controls
  .Add(MsoControlType.msoControlComboBox, missing, missing, 1, true);

ctrl.Caption = "Bleh";
ctrl.Text = "Blah";
ctrl.AddItem("Hai", 1);
ctrl.AddItem("Hoi", 2);
ctrl.DropDownLines = 3;
ctrl.DropDownWidth = 75;
ctrl.ListIndex = 0;
ctrl.Visible = true;

上面的代码在 Word 的右键单击上下文菜单中添加了一个菜单,称为“我的菜单”,然后我尝试在该菜单中添加一个组合框,它没有显示。代码在我的插件启动函数中。

有人有这方面的经验吗?有可能吗?还是我只是在做完全错误的事情?



更新

我想在某处有一些关于此的文档。但我似乎无法找到它。这是我找到的文档:
http://msdn.microsoft.com/en-us/library/aa190799(v=office.10).aspx
通过阅读,我得到的印象是应该可以添加 CommandBarPopup、CommandBarComboBox 和 CommandBarButton。

【问题讨论】:

    标签: c# ms-word ms-office add-in office-addins


    【解决方案1】:

    据我所知,您不能将任何“编辑”控件放在菜单中,只能将它们放在工具栏中。如果我没记错的话,菜单可以包含分隔符或 MenuCommandButtons 或子菜单。

    【讨论】:

    • 我怀疑你是对的,但如果能获得一些关于此的文档会很好。我没有找到任何东西,但我确定它存在于某个地方。你知道在哪里吗?
    猜你喜欢
    • 2014-07-14
    • 2016-04-02
    • 2014-06-18
    • 2012-04-05
    • 1970-01-01
    • 2014-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多