Delphi Classes-FindComponent 通过文本字符串名称,寻找组件(控件)
Delphi Classes-FindComponent 通过文本字符串名称,寻找组件(控件)
引用单元:Classes
函数原型:
function TComponent.FindComponent(const AName: string): TComponent;
var
  I: Integer;
begin
  if (AName <> '') and (FComponents <> nil) then
    for I := 0 to FComponents.Count - 1 do
    begin
      Result := FComponents[I];
      if SameText(Result.FName, AName) then Exit;
    end;
  Result := nil;
end;
Delphi 使用示例:
var 
  sLabel: TComponent;
begin
  sLabel:= FindComponent("Label1");
  If sLabel is TLabel then
    TLabel (sLabel ).Caption:=' Delphi';
end;
创建时间:2020.05.27 更新时间:
    博客园 滔Roy https://www.cnblogs.com/guorongtao 希望内容对你有所帮助,谢谢!
 
                    
                     
                    
                 
                    
                 
                
            
         
 
         浙公网安备 33010602011771号
浙公网安备 33010602011771号