添加自定义图像到按钮,在Excel功能区 [英] Add Custom Image to button in excel ribbon
问题描述
我正在开发一个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功能区的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!