我将控件名(image1...)保存到TList中然后,我要在后面使用保存的控件,但只能从tlist中得到保存的字符串!而他不识别为控件?????代码如下: type
  PMyList = ^AList;
  AList = record
    C: string;
  end;
var List: TList;
    ARecord:PMylist;
begin
  list:=tlist.Create;  new(ARecord);
  ARecord^.c:='img';
  List.Add(ARecord);
  img.Stretch:=true;
  ARecord:=list.Items[0];// ARecord^.c只得到字符串‘img’,并不能识别为控件名????
//这里我要建img控件,并调图?????    dispose(ARecord);
  list.Free;

解决方案 »

  1.   

    啊 啊? 头一次听说还有这种调控件的方法咧....
    要建image控件,就要声明TImage实例,再创建啊.
    不明白你为什么要这么做? 
    你想实现什么呢?
      

  2.   

    楼主:
    PMyList = ^AList;
      AList = record
        C: string;
      end;你放进去的本身就只是一个string嘛!哪里是什么对象?
    你用TObjectList来做你想做的这个事吧!
      

  3.   

    补充:看看delphi的help,有例子的。
      

  4.   

    我要用很多的控件,我要把它保存起来,以后用到一个建一个就可以了???
    用数组保存也可,只是便于以后我用编号来调用前面我已经声明了   在这里我要创建:
       img:=timage.Create(form1);//img是保存在TLIST中的,如保写
       img.Parent:=form1;
       img.Visible:=true;
      

  5.   

    你要保存控件的话,需要保存的是指针更改代码如下:
    var List: TList;
    begin
      list:=tlist.Create;
      //保存控件与列表
      List.Add(Image1);//其实保存的是指针
      List.Add(Edit1);
      ..... 
    将来如果想访问,就这样 : 
    if List.Items[0] is  TImage then
         (List.Items[0] As TImage).Strech := true;
    if List.items[1] it TEdit then
          (List.items[1] As TEdit).text := 'h';