gpt4 book ai didi

c# - 如何使用功能区 xml 将图像添加到按钮?

转载 作者:太空狗 更新时间:2023-10-29 17:30:52 24 4
gpt4 key购买 nike

如何将自定义图像添加到选项卡和上下文菜单中的功能区按钮。

我尝试了将图像添加到功能区按钮的链接,但没有成功:-(。我正在为 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>

代码片段

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 插件。

最佳答案

您必须为每个按钮使用 getImage 属性,并且回调应该返回位图。

在 Ribbon.xml 中

<button id="btnLogo" getImage="imageSuper_GetImage" size="large" />

丝带.cs

public Bitmap imageSuper_GetImage(IRibbonControl control)
{
return Resources.super_logo;
}

关于c# - 如何使用功能区 xml 将图像添加到按钮?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21543037/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com