添加自定义图像到按钮,在Excel功能区

编程入门 行业动态 更新时间:2024-10-08 04:29:32
本文介绍了添加自定义图像到按钮,在Excel功能区的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在开发一个Microsoft Excel插件,并添加一个按钮,但我需要自定义图像添加到它。如何做到这一点。

<按钮ID =customButton1标签=myLabel大小=大形象=? ??? />

解决方案

尝试在代码隐藏使用此代码片段:

customButton1.Image =新位图(image.jpg文件);

customButton1.Image = Image.FromFile(@C:\Image.jpg);

的如何添加自定义图标到工具栏和菜单项

  • 创建一个名为ConvertImage新类。这个类使用System.Forms.Axhost转换的图像文件可以被施加到菜单项的图像类型。

  • 添加的方法来转换图标将其添加到一个ImageList文件转换为图像文件。此代码发送映像文件到您创建的ConvertImage.Convert方法,然后返回文件给调用者。

  • I'm developing a microsoft excel addin and added a button, but I need to add custom image to it. How to achieve that

    <button id="customButton1" label="myLabel" size="large" image="????" />

    解决方案

    Try using this code snippet in the code-behind:

    customButton1.Image = new Bitmap("Image.jpg");

    OR

    customButton1.Image = Image.FromFile(@"C:\Image.jpg");

    How to: Add Custom Icons to Toolbar and Menu Items

  • Create a new class named ConvertImage. This class uses System.Forms.Axhost to convert an image file to an image type that can be applied to the menu item.

  • Add a method to convert the icon file into an Image file by adding it to an ImageList. This code sends the Image file to the ConvertImage.Convert method you created and then returns the file to the caller.

  • 更多推荐

    添加自定义图像到按钮,在Excel功能区

    本文发布于:2023-10-31 10:26:25,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1545808.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:自定义   按钮   图像   功能   Excel

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!