如何動態得到組件名?如寫一個函数返回組件名?

解决方案 »

  1.   

    for i:=0 to Componentcount-1 do 
         showmessage(components[i].name); 
      

  2.   

    要動態返回組件名,不要遍力整個form
      

  3.   

    function getReport( reportName:string ):TReport;
    begin
      //静态指定/动态查找 组件
      Result:=组件;
    end;
      

  4.   

    function getReport( reportName:string ):TReport;
    begin
    //静态指定/动态查找 组件
    case reportname of
      '编号aa':Result:=组件aa;
      '编号bb':Result:=组件bb;
    end;
    end;
      

  5.   

    TO :  hongqi162
    我的組件命命是以Report+所輸入的編號
    如 ; Report020 
      

  6.   

    var
      I:Integer;
    begin
      Result:=nil;
      for i:=0 to self.ComponentCount-1 do
      begin
        if self.Components[i].Name = 'Report'+ReportName then
          Result:= self.Components[i];
      end;
      

  7.   

    TO: hongqi162
      編號如果不是數字那不就是不能用
      

  8.   

    TO: hongqi162
      返回了組件名,但怎麼給它事件 如 ;組件名.Prepare
    函数返回的組件編譯不了.我是這樣寫的TQuickRep(GetForm(edtCODE.Text)).Prepare;