如何动态加载VSTO图库控件

时间:2013-12-09 14:10:43

标签: vsto

我正在寻找描述VSTO图库控件如何动态加载的示例代码或文档

tx

1 个答案:

答案 0 :(得分:2)

这是一个动态加载图库中图像的示例。

<强> Ribbon.xml

<gallery id="galleryConvertTable" columns="1" onAction="galleryConvertTable_Click"
         getItemCount="galleryConvertTable_getItemCount"
         imageMso="CreateTable" size="large" label="Convert to Table"
         getEnabled="galleryConvertTable_getEnabled"
         getItemImage="tableforNumbers_getImage">                     
</gallery>

<强> Ribbon.cs

public int galleryConvertTable_getItemCount(Office.IRibbonControl control)
{
   return GetTableStylesCount();
}

public void galleryConvertTable_Click(Office.IRibbonControl control, string selectedId, int selectedIndex)
{
    ConvertToTable(selectedIndex);
}

public Bitmap tableforNumbers_getImage(Office.IRibbonControl control, int itemIndex)
{
    switch (itemIndex)
    {
       case 0:
           return Resources.TableforNumbers;
       case 1:
           return Resources.TableforNumbersWithLines;
       case 2:
           return Resources.TableforText;
       case 3:
           return Resources.TableforTextwithLines;
     }
     return Resources.TableforNumbers;
}

如果您将getItemImage更改为getItemLabel且方法签名为

public string getItemLabel(IRibbonControl control, int index)

MSDN

中的更多内容