IGxImageList.Add

Syntax

Add(Image: IGxBitmap; [Transparent: IGxColor = Null]);

Parameters

Image. Image to be added to the collection.

Transparent. Optional parameter that determines the color that is used as a transparent one.

Description

The Add method adds the image passed by the Image parameter to the collection of images.

Example

Executing the example requires a form with the button named Button1, the ImageList non-visual component named ImageList1, the TreeList component named TreeList1. Add images to the ImageList component and determine a link with the source of the ImageList1 image collection in the StateImages and Images properties of the TreeList component. Create five elements in the TreeList component and determine icons to them from the collection of images. The file system should also contain the image: C:\1.bmp. At least five icons should be in the collection and in the image. Add links to the Drawing, Forms, Io system assemblies.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    ImgList: IGxImageList;
    Str: IIOStream;
    Color: IGxColor;
Begin
    Color := GxColor.FromKnownColor(GxKnownColor.White);
    // Create a collection of images and add icons from file
    ImgList := New GxImageList.Create;
    ImgList.Add(New GxBitmap.CreateFromFile("C:\1.bmp"), Color);
    // Replace icons in the component with collection of images via the stream
    Str := New MemoryStream.Create;
    ImgList.SaveToStream(Str, Color);
    ImageList1.LoadFromStream(Str, Color);
End Sub Button1OnClick;

After executing the example clicking the button in the TreeList component replaces the added icons with the icons from the specified file C:\1.bmp.

See  also:

IGxImageList