Bonjour
Est-ce que quelqu'un aurait la gentillesse de m'expliquer pourquoi avec ce code :
//list image in thumbtmp : 0.jpg, 1.jpg, 2.jpg....
SL := FindAllFilesEx('thumbtmp','*',True, faDirectory);
ImageList1.BeginUpdate;
ListView1.Items.BeginUpdate;
try
for i:=0 to SL.Count-1 do
begin
jpg := TJpegImage.Create;
jpg.LoadFromFile(SL[i]);
ImageList1.Add(jpg, nil);
end;
finally
for j := 0 to ImageList1.Count - 1 do
begin
LI := ListView1.Items.Add;
LI.Caption := 'blabla....';
LI.ImageIndex := j;
LI.SubItems.Add('blabla....');
LI.SubItemImages[0] := j; // SubItems[ColumnIndex] := ImageIndex;
end;
Listview1.Items.EndUpdate;
ImageList1.EndUpdate;
end;
SL.Free;
Mon dossier thumbtmp contient des images nommées 0.jpg, 1.jpg, 2.jpg ....
Or quand je les affiches dans ma Listview1 elles apparaissent n'importe comment, elle ne respecte pas l'ordre alphabétique.
J'ai essayé aussi de les faire apparaitre par date de création mais rien à faire... L'ordre est aléatoire, aucune logique mais c'est toujours le même par contre.
Si quelqu'un a une idée, je le remercie d'avance !
----------------------------------------------
Hello
Would anyone be kind enough to explain to me why with this code:
//list image in thumbtmp : 0.jpg, 1.jpg, 2.jpg....
SL := FindAllFilesEx('thumbtmp','*',True, faDirectory);
ImageList1.BeginUpdate;
ListView1.Items.BeginUpdate;
try
for i:=0 to SL.Count-1 do
begin
jpg := TJpegImage.Create;
jpg.LoadFromFile(SL[i]);
ImageList1.Add(jpg, nil);
end;
finally
for j := 0 to ImageList1.Count - 1 do
begin
LI := ListView1.Items.Add;
LI.Caption := 'blabla....';
LI.ImageIndex := j;
LI.SubItems.Add('blabla....');
LI.SubItemImages[0] := j; // SubItems[ColumnIndex] := ImageIndex;
end;
Listview1.Items.EndUpdate;
ImageList1.EndUpdate;
end;
SL.Free;
My thumbtmp folder contains images named 0.jpg, 1.jpg, 2.jpg ....
But when I post them in my Listview1 they appear anyhow, it does not respect the alphabetical order.
I also tried to make them appear by date of creation but nothing to do ... The order is random, no logic but it is always the same cons.
If anyone has an idea, I thank him in advance!