Add Custom Image to button in excel ribbon

☆樱花仙子☆ 提交于 2019-12-08 13:44:33

问题


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="????" />

回答1:


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

  1. 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.

  2. 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.



来源:https://stackoverflow.com/questions/14032644/add-custom-image-to-button-in-excel-ribbon

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!