ICreate.Controls.Bars Send comments on this topic.
Image Property
See Also  Example
ICreate.Controls.Bars Namespace > CommandItem Class : Image Property






Gets or sets the image displayed on the CommandItem.

Syntax

Visual Basic (Declaration) 
Public Property Image As Image
Visual Basic (Usage)Copy Code
Dim instance As CommandItem
Dim value As Image
 
instance.Image = value
 
value = instance.Image
C# 
public Image Image {get; set;}
Delphi 
public read-write property Image: Image; 
JScript 
public function get,set Image : Image
Managed Extensions for C++ 
public: __property Image get_Image();
public: __property void set_Image( 
   Image value
);
C++/CLI 
public:
property Image Image {
   Image get();
   void set (Image value);
}

Return Value

An reference to an Image, this property specifies the image displayed on the CommandItem. Its value is null (Nothing in Visual Basic) if the CommandItem has no image. The default value is null.

Example

The example below shows how to set a number of CommandItem properties including Image. To run this example, create a WinForm application and define the Form as shown below. Compile and run the application.

C#Copy Code
using System; 
using System.Drawing; 
using System.Windows.Forms; 
 
using ICreate.Controls.Bars; 
 
namespace ExamplesCSharp 

    public partial class SetCommandItemProperties : Form 
    { 
        public SetCommandItemProperties() 
        { 
            InitializeComponent(); 
 
            commandButton.TextImageRelation = TextImageRelation.ImageAboveText; 
            commandButton.Text = "Open"; 
            commandButton.Image = Image.FromFile("Resources\\Open.ico"); 
            commandButton.Tip = "Open the file"; 
            commandButton.TipAppearance = TipAppearance.Gradient; 
            commandButton.ForeColor = Color.Gray; 
            commandButton.BackColor = Color.LightBlue; 
            commandButton.ButtonStyle = ButtonStyle.Vista; 
        } 
    } 
}
Visual BasicCopy Code
Imports ICreate.Controls.Bars

Public Class SetCommandItemProperties

    Public Sub New()

        InitializeComponent()

        CommandButton.TextImageRelation = TextImageRelation.ImageAboveText
        CommandButton.Text = "Open"
        CommandButton.Image = Image.FromFile("Resources\\Open.ico")
        CommandButton.Tip = "Open the file"
        CommandButton.TipAppearance = TipAppearance.Gradient
        CommandButton.ForeColor = Color.Gray
        CommandButton.BackColor = Color.LightBlue
        CommandButton.ButtonStyle = ButtonStyle.Vista

    End Sub

End Class

Remarks

There are a number of ways to specify the image on the CommandItem. The Image property; specify an ImageList and the index of the image in the image list using the ImageIndex property; or specify an ImageList and the name of the image in the image list using the ImageKey property.

If you specify one of these properties then the other two will be reset to their default value. For example if you specify Image then ImageIndex will be reset to -1 and ImageKey to the empty string.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also