Frequently Asked Component Specific Questions
Options |
Display all FAQ items |
Displaying items 1 to 1 of 1, page 1 of 1
<< previous next >>
TAdvSmoothImageListBox
Adding items & extra properties in code
Adding items & extra properties in code
In this code sample, the image will be directly (non threaded) loaded in the TAdvSmoothImageListBox:
procedure TForm1.AddItems; var i: integer; begin //Adds 20 items for i := 0 to 20 do begin with AdvSmoothListBox.Items.Add do begin Enabled := True; //If enabled false then the item will be drawn in disabled fill Visible := false; //the item will be invisible Image.LoadFromFile(‘image1.jpg’); //the image will be loaded on the item Caption.Text := ‘Item ’+ inttostr(i); Splitter := false; //if splitter is true a splitter will be drawn between the items … end; end; end;
To have the listbox background thread load the images for higher responsiveness of the application, following code can be used:
procedure TForm1.AddItems; var i: integer; begin //Adds 20 items for i := 0 to 20 do begin with AdvSmoothListBox.Items.Add do begin Enabled := True; //If enabled false then the item will be drawn in disabled fill Visible := false; //the item will be invisible Location := ‘image1.jpg’; //the image will be loaded by thread Caption.Text := ‘Item ’+ inttostr(i); Splitter := false; //if splitter is true a splitter will be drawn between the items … end; end; end;
You can also add a whole directory of images either threaded or not threaded. When the threaded method is choosen, the images are loaded via a separate thread. This separate thread loads only the visible images for efficiency. As the list is scrolled, new visible item‟s images will be loaded by this thread.
Not threaded:
AdvSmoothImageListBox.AddImagesFromFolder(„C:\directory\*.jpg‟);
AdvSmoothImageListBox.AddImageLocationsFromFolder(„C:\directory\*.jpg‟);
Image types supported are: jpg, jpeg, bmp, png, gif, tiff and ico.