Sdílet prostřednictvím


RibbonLoadImageEventArgs Interface

Definition

Provides data for the LoadImage event.

public interface class RibbonLoadImageEventArgs
[System.Runtime.InteropServices.Guid("faacd97a-39b2-4c40-a1c2-6eec43ce950f")]
public interface RibbonLoadImageEventArgs
[<System.Runtime.InteropServices.Guid("faacd97a-39b2-4c40-a1c2-6eec43ce950f")>]
type RibbonLoadImageEventArgs = interface
Public Interface RibbonLoadImageEventArgs
Attributes

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.

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;
    }
}
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

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.

Properties

Image

Gets or sets the image of a Ribbon control that you want to load.

ImageName

Gets the name of the image that is being loaded in the Ribbon.

Applies to