如何使用功能区 xml 将图像添加到按钮? [英] How can I add the images to button using the ribbon xml?
本文介绍了如何使用功能区 xml 将图像添加到按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将自定义图像添加到选项卡和上下文菜单中的功能区按钮.
How to add the custom images to the ribbon button in the tab and the context menu.
我尝试了将图像添加到功能区按钮的链接,但没有成功:-(.我正在为 Excel 设计插件.我在标题中添加了这个.
I tried the link Adding Image to ribbon button but no luck :-(. I am designing the addin for Excel. I added this in the header.
<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>
代码片段
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;
}
请帮我解决这个问题.我正在为 Office 2010 使用 .net 4.0 c# VSTO excel 插件.
Please help me in this. I am using .net 4.0 c# VSTO excel addin for Office 2010.
推荐答案
您必须为每个按钮使用 getImage
属性,并且回调应返回位图.
You have to use getImage
property for each button and the callback should return bitmap.
在 Ribbon.xml 中
In Ribbon.xml
<button id="btnLogo" getImage="imageSuper_GetImage" size="large" />
Ribbon.cs
public Bitmap imageSuper_GetImage(IRibbonControl control)
{
return Resources.super_logo;
}
这篇关于如何使用功能区 xml 将图像添加到按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文