我的程序是这样的,打开一个openpicturedialog对话框(可以多选),然后用循环让image1至image6组件装入对话框里多选的图片文件:
procedure TForm1.openClick(Sender: TObject);
var
c_file,c_i,i:integer;
begin
  if OPDa.Execute then
    begin
      c_file:=opda.Files.Count;
      if c_file>=8 then c_i:=8;
      if c_file<8 then c_i:=c_file;
    //==============================
      for i:=0 to c_i-1 do
        begin
          image“动态的随i变化”.Picture.LoadFromFile(OPDa.Files.Strings[i]);
        end;
    end;
end;但是直接写
imagei.Picture.LoadFromFile(OPDa.Files.Strings[i]);
不行,说找不到imagei组件
请问如何实现我的功能

解决方案 »

  1.   

    for cIndex := 0 to ComponentCount - 1 do
        if Component[cIndex] is Timage then
           (Component[cIndex] as Timage).Picture.LoadFromFile(OPDa.Files.Strings[i]);//可能我写错了,但是大体就是这个意思,等我装了delphi再帮你测试
      

  2.   

    用FindComponent...  TImage(Self.FindComponent('image' + inttostr(i))).Picture.LoadFromFile(OPDa.Files.Strings[i]);
    有点长,自己整理一下