Share via


OfficeRibbon.LoadImage Event (2007 System)

Occurs when the OfficeRibbon loads, if the ImageName property is set for one or more controls.

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

Syntax

'Declaration
<RibbonEventAttribute("loadImage")> _
Public Event LoadImage As EventHandler(Of RibbonLoadImageEventArgs)
'Usage
Dim instance As OfficeRibbon 
Dim handler As EventHandler(Of RibbonLoadImageEventArgs)

AddHandler instance.LoadImage, handler
[RibbonEventAttribute("loadImage")]
public event EventHandler<RibbonLoadImageEventArgs> LoadImage
[RibbonEventAttribute(L"loadImage")]
public:
 event EventHandler<RibbonLoadImageEventArgs^>^ LoadImage {
    void add (EventHandler<RibbonLoadImageEventArgs^>^ value);
    void remove (EventHandler<RibbonLoadImageEventArgs^>^ value);
}
JScript does not support events.

Remarks

The LoadImage event enables you to cache images in the Ribbon customization, which can improve performance.

By default, an image is loaded into the Ribbon every time the user displays a tab that contains the image. An image is reloaded any time that you programmatically change the properties of a control on which the image appears.

Use the LoadImage event to assign an image to a control. When the user selects a tab on the Ribbon, the Microsoft Office application uses the cached image. If you modify a control property at run time, the Microsoft Office application will not reload the image on the control. This can give you a small performance gain.

If you want to cache the image of a control, set the ImageName property of the control. The LoadImage event is not raised unless you set the ImageName property of at least one control.

Examples

The following example caches the images for two RibbonButton controls.

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

  • Add a Ribbon (Visual Designer) to a Visual Studio Tools for Office project.

  • If you are using a Visual Basic project, add the following statement to the top of the Ribbon code file: Imports Microsoft.Office.Tools.Ribbon

You can then run this code in the generated Ribbon class.

Private Sub Ribbon1_LoadImage(sender As Object, 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;
    }
}

.NET Framework Security

See Also

Reference

OfficeRibbon Class

OfficeRibbon Members

Microsoft.Office.Tools.Ribbon Namespace