我正在开发一个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功能区
发布评论