IImageList.LoadFromFile

Syntax

LoadFromFile(Value: String; [Transparent: IGxColor = Null]);

Parameters

Value. The parameter determines the string that specifies path to the file to be loaded to the component.

Transparent. This parameter determines the color to be used as transparent.

Description

The LoadFromFile method loads an image in the component from the file, the path and name of which are passed by the Value parameter.

Example

Executing the example requires a form with a button named Button1, a button named Button2, the TreeList component named TreeList1 with added element, the ImageList component named ImageList1, the FileOpenDialog component named FileOpenDialog1. Add links to the Drawing, Forms system assemblies. The file system should include an image with the images as a horizontal line: C:\temp\1.bmp.

Sub Button1OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Node: ITreeListNode;
Begin
    ImageList1.LoadFromFile("C:\temp\1.bmp", GxColor.FromName("White"));
    TreeList1.Images := ImageList1;
    Node := TreeList1.Nodes.FirstNode;
    Node.ImageIndex := 1;
    Text := ImageList1.Count.ToString;
End Sub Button1OnClick;

Sub Button2OnClick(Sender: Object; Args: IMouseEventArgs);
Var
    Node: ITreeListNode;
Begin
    If FileOpenDialog1.Execute Then
        ImageList1.LoadFromFile(FileOpenDialog1.FileName, GxColor.FromName("White"));
        TreeList1.Images := ImageList1;
        Node := TreeList1.Nodes.FirstNode;
        Node.ImageIndex := 1;
        Text := ImageList1.Count.ToString;
    End If;
End Sub Button2OnClick;

Clicking the Button1 button in the TreeList component displays the second icon of the specified image and displays the number of icons in the form name. Clicking the Button2 button displays a dialog box to open an image, after that the second icon of the image and the number of icons in the form name are displayed in the TreeList component.

See also:

IImageList