Share via


RibbonLoadImageEventArgs Class (2007 System)

Provides data for the LoadImage event.

Namespace:  Microsoft.Office.Tools.Ribbon
Assembly:  Microsoft.Office.Tools.Common.v9.0 (in Microsoft.Office.Tools.Common.v9.0.dll)

Syntax

'Declaration
Public NotInheritable Class RibbonLoadImageEventArgs _
    Inherits EventArgs
'Usage
Dim instance As RibbonLoadImageEventArgs
public sealed class RibbonLoadImageEventArgs : EventArgs
public ref class RibbonLoadImageEventArgs sealed : public EventArgs
public final class RibbonLoadImageEventArgs extends EventArgs

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 a Visual Studio Tools for 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;
    }
}

Inheritance Hierarchy

System.Object
  System.EventArgs
    Microsoft.Office.Tools.Ribbon.RibbonLoadImageEventArgs

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

RibbonLoadImageEventArgs Members

Microsoft.Office.Tools.Ribbon Namespace