如題。
我想用一個循環得到當前表單的名稱,然後對它們的屬性統一設置,請問怎麼搞?
謝謝。

解决方案 »

  1.   

    for i := 0 to Self.ComponentCount-1 do
      begin
        if Self.Components[i].ClassName = 'TLabel' then
        begin
          TLabel(Components[i]).Top:= TLabel(Components[i]).Top - 2;
          if TLabel(Components[i]).Width >= Image16.Width - 5 then
            TLabel(Components[i]).Caption := Copy(TLabel(Components[i]).Caption,1,34) + '...';
    {      if TLabel(Components[i]).Top = Image16.Top then
          begin
            TLabel(Components[i]).Visible := False;
          end;}
          //label超过image16的顶即不可见
          if TLabel(Components[i]).Top = Image16.Top then TLabel(Components[i]).Visible := False;
          if TLabel(Components[i]).Top = 472 then TLabel(Components[i]).Visible:= True;
        end;
      end;