Icons

There are a large number of built-in icons which you can use or you can design and use your own.


Built-in Icons

If you are using the Ribbon Designer you need to change the OfficeImageId property.
SS
If you are using a Ribbon.xml file and want a built-in image you can use the "imageMso" element.

<button id="Button1" imageMso="HappyFace" /> 

Custom Icons

If you are using the Ribbon Designer you need to add your custom icons to your solution, and reference them on the controls using the Image property.
If you are using a Ribbon.xml file you need to include the loadImage="Ribbon_LoadImage" at the top of your XML file.

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load" loadImage="Ribbon_LoadImage"> 
  <ribbon>

Create your custom icons and add them to the project resources.
SS
Instead of the "imageMso" element you need to use the "image" element.
The name of your image needs to correspond exactly with the name of the image in your resources.

<button id="Button1" image="Resource_Name" /> 

Add the following code to the bottom of your Ribbon.cs file.

public object Ribbon_LoadImage(string resourceName) 
{
    System.Drawing.Bitmap bitmap = (System.Drawing.Bitmap)Properties.Resources.ResourceManager.GetObject(resourceName);

    return (stdole.IPictureDisp)System.Windows.Forms.AxHost.GetIPictureDispFromPicture(bitmap);
}

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext