roo*_*i n 9 .net c# vsto ribbon
如何将自定义图像添加到选项卡和上下文菜单中的功能区按钮.
我尝试了添加图像到功能区按钮的链接,但没有运气:-(.我正在设计Excel的插件.我在标题中添加了这个.
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" loadImage="Ribbon_LoadImage">
<button id="btn2d" keytip="L" screentip="2D Visualization" supertip="2D Part Visualization" label="2D" size="large"/>
<contextMenu idMso="ContextMenuCell">
<button id="btn1" label="my label"/>
</customUI>
Run Code Online (Sandbox Code Playgroud)
代码段
public Bitmap Ribbon_LoadImage(IRibbonControl control)
{
switch (control.Id)
{
case "btn2": return new Bitmap(Properties.Resources.btn1);
case "btn3": return new Bitmap(Properties.Resources.btn2);
case "btn4": return new Bitmap(Properties.Resources.btn3);
case "btn5": return new Bitmap(Properties.Resources.Filter);
case "btnOpt6": return new Bitmap(Properties.Resources.Settings);
case "btnInform7": return new Bitmap(Properties.Resources.Vis);
case "btnHelpPage": return new Bitmap(Properties.Resources.Help);
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
请帮帮我.我正在使用.net 4.0 c#VSTO excel addin for Office 2010.
Kir*_*iru 27
您必须getImage为每个按钮使用属性,并且回调应返回位图.
在Ribbon.xml中
<button id="btnLogo" getImage="imageSuper_GetImage" size="large" />
Run Code Online (Sandbox Code Playgroud)
Ribbon.cs
public Bitmap imageSuper_GetImage(IRibbonControl control)
{
return Resources.super_logo;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15060 次 |
| 最近记录: |