Compartilhar via


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)

Syntax

'Declaration
<GuidAttribute("faacd97a-39b2-4c40-a1c2-6eec43ce950f")> _
Public Interface RibbonLoadImageEventArgs
[GuidAttribute("faacd97a-39b2-4c40-a1c2-6eec43ce950f")]
public interface RibbonLoadImageEventArgs

The RibbonLoadImageEventArgs type exposes the following members.

Properties

  Name Description
Public property Image Gets or sets the image of a Ribbon control that you want to load.
Public property ImageName Gets the name of the image that is being loaded in the Ribbon.

Top

Remarks

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.

Examples

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 Sub Ribbon1_LoadImage(ByVal sender As Object, _
    ByVal e As RibbonLoadImageEventArgs)
    Select Case e.ImageName
        Case "Button1Image"
            e.Image = My.Resources.Image1
        Case "Button2Image"
            e.Image = My.Resources.Image2
    End Select 
End Sub
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;
    }
}

See Also

Reference

Microsoft.Office.Tools.Ribbon Namespace