Export (0) Print
Expand All

RibbonLoadImageEventArgs Interface

Provides data for the LoadImage event.

Namespace:  Microsoft.Office.Tools.Ribbon
Assemblies:   Microsoft.Office.Tools.Common (in Microsoft.Office.Tools.Common.dll)
  Microsoft.Office.Tools.Common.v4.0.Utilities (in Microsoft.Office.Tools.Common.v4.0.Utilities.dll)

[GuidAttribute("faacd97a-39b2-4c40-a1c2-6eec43ce950f")]
public interface RibbonLoadImageEventArgs

The RibbonLoadImageEventArgs type exposes the following members.

  NameDescription
Public propertyImageGets or sets the image of a Ribbon control that you want to load.
Public propertyImageNameGets the name of the image that is being loaded in the Ribbon.
Top

Handle the LoadImage event if you want to load an image that is identified by the ImageName property of a control. The Microsoft Office application retrieves this image from your solution only once, when the Ribbon is displayed, to improve performance. After that, the control image cannot be changed.

To load an image for a control, add code to the LoadImage event handler. If the ImageName property of the RibbonLoadImageEventArgs matches the ImageName property of the control, set the Image property to the image that you want to load.

The following example caches the images for two RibbonButton controls.

To run this code example, you must first perform the following steps:

  1. Add a Ribbon (Visual Designer) item to an Office project.

  2. Add a group to the custom tab.

  3. Add two buttons to the group.

  4. Add two images to the project resources. For more information, see How to: Add or Remove Resources.

private void Ribbon1_LoadImage(object sender, RibbonLoadImageEventArgs e)
{
    switch (e.ImageName)
    {
        case "Button1Image":
            e.Image = Properties.Resources.Image1;
            break;
        case "Button2Image":
            e.Image = Properties.Resources.Image2;
            break;
    }
}
Show:
© 2014 Microsoft