我正在寻找描述VSTO图库控件如何动态加载的示例代码或文档
tx
答案 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)
中的更多内容