Можно использовать список:
Код:
var
L : TList;
procedure TForm1.FormCreate(Sender: TObject);
begin
L := TList.Create;
L.Add(ComboBox1);
L.Add(ComboBox2);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
L.Free;
end;
procedure TForm1.DrawIconFile;
var
x: string;
o, i, k, b, id: integer;
cb:TComboBox;
begin
for k:=0 to L.Count-1 do
begin
cb := (TObject(L.Items[k]) as TComboBox);
cb.ItemIndex := 0;
b := 0;
o := 0;
for i:=0 to cb.ItemsEx.Count-1 do
begin
id := cb.ItemIndex + b;
x:=copy(cb.Items[id],length(cb.Items[id])-3,length(cb.Items[id]));
if x = '.doc' then o := 3
else if x = 'docx' then o := 0
else if x = '.xls' then o := 2
else if x = 'xlsx' then o := 1;
cb.ItemsEx[id].ImageIndex := o;
Inc(b);
end;
end;
end;