RibbonButton.Image Property (2007 System)
Gets or sets the image that is displayed on the button.
Namespace: Microsoft.Office.Tools.Ribbon
Assembly: Microsoft.Office.Tools.Common.v9.0 (in Microsoft.Office.Tools.Common.v9.0.dll)
Syntax
'Declaration
Public Property Image As Image
'Usage
Dim instance As RibbonButton
Dim value As Image
value = instance.Image
instance.Image = value
public Image Image { get; set; }
public:
property Image^ Image {
Image^ get ();
void set (Image^ value);
}
public function get Image () : Image
public function set Image (value : Image)
Property Value
Type: System.Drawing.Image
An Image that is displayed on the button.
Remarks
The recommended image format is PNG, because images in the PNG format support transparency through their alpha channel.
The Image property identifies an image that is displayed by the control. This property can be set at design time or at run time. If you update this property at run time, the control's appearance is updated to reflect the change.
If the Image property is set, the OfficeImageId and ImageName properties are ignored. Although the Image property gives you more control than the other two properties do, it can be slower because the image object is sent to the Office application every time the control is updated.
The ShowImage property must be true for the control to display the image. When you set the Image property at design time, Visual Studio Tools for Office automatically sets the ShowImage property to true. If you set the Image property at run time, you must set the ShowImage property to true in your code.
Examples
The following example sets the Image property of two buttons. To run this code example, you must first perform the following steps:
Add a Ribbon (Visual Designer) item to a Visual Studio Tools for Office project.
Add a group to the custom tab.
Add two buttons to the group.
Add two images to the project resources. For more information, see How to: Add or Remove Resources.
Private Sub LoadImages()
button1.ShowImage = True
CustomerButton.ShowImage = True
Button1.Image = My.Resources.Image1
CustomerButton.Image = My.Resources.Image2
End Sub
private void LoadImages()
{
button1.ShowImage = true;
button2.ShowImage = true;
button1.Image = Properties.Resources.Image1;
button2.Image = Properties.Resources.Image2;
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
See Also
Reference
Microsoft.Office.Tools.Ribbon Namespace