Insertion dans un TObjectList
Bonjour à tous,
Mon but est d'inverser deux Combobox stockées dans un TObjectList en fonction de la valeur de leurs tags:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| MaCombo : TComboBox;
procedure TForm4.TrierCombo;
var i,j,k:integer;
begin
for i:=0 to TObjectList .Count-2 do
for j:=i+1 to TObjectList .Count-1 do
begin
if (TCombobox(TObjectList .items[i]).Tag > TCombobox(TObjectList.items[j]).Tag) then
begin
MaCombo := TCombobox(ComboCatenaire.items[j]);
ComboCatenaire.delete(j);
ShowMessage(IntToStr(MaCombo.Tag));
ComboCatenaire.insert(i,MaCombo as TComboBox);
ShowMessage(IntToStr(MaCombo.Tag));
end;
end;
end |
Le problème c'est qu'apparemment toutes les propriétées relatives à ma combobox ont disparues (par exemple le tag passe de 0 avant l'insert, à 19773984 après). Je suppose que cela vient du fait que insert accepte en paramètre un TObject, mais alors comment lui passer une TCombobox?
Merci bocoup,
@+.