TListView - How to Resize Items on Resize
I have a TListView that displays small thumbnails (ViewStyle:=vsIcon)
. At runtime, I assign images to elements:
for i := 0 to Total - 1 DO
with ListView.Items.Add DO
begin
Caption := 'Item ' + IntToStr(i);
ImageIndex := i;
end;
When launched, the shape is not very wide and the thumbnails are only displayed in 3 columns. Unfortunately, if I resize the form (and the ListView ), the number of columns stays at 3 and there are a lot of spaces on the right side.
This won't work either:
procedure TForm1.FormCreate(Sender: TObject);
begin
ListView.IconOptions.AutoArrange := TRUE;
end;
How do I reorder the elements to fill the empty space? Is there any property like AutoArrange?
Update:
I removed the old control and I put the new one on the form.
Now it works ListView.IconOptions.AutoArrange
. There was something in the previous item (some tweaks I made) that was preventing AutoArrange from working.
source to share
There is a type property AutoArrange
. It refers to a property IconOptions
, not directly to the list view.
ListView1.IconOptions.AutoArrange := True;
To do a one-time icon layout you can call ListView_Arrange
.
source to share