为 RibbonComboBox 动态设置 Selected Item(在运行时)?

Dynamically set Selected Item for RibbonComboBox (on runtime)?

如何在 VSTO 中以编程方式为 RibbonComboBox 设置选定项? 我用 C#.

myRibbonCB.SelectedItem = "label-name";

不存在。

您需要在功能区中定义回调并在 C# 代码中实现这些回调。为 C# VSTO 示例尝试以下 link: http://blogs.infoextract.in/office-ribbon-customization-vsto-using-c/

简而言之:

丝带XML:

<toggleButton id="toggleButton1" onAction="OnActionCallback" />

C#:

public void OnActionCallback(Office.IRibbonControl control, bool isPressed)
{
    if (control.Id == "checkBox1")
    {
        MessageBox.Show("You clicked " + control.Id);
    }
    else
    {
        MessageBox.Show("You clicked a different control.");
    }
}