Thema: Delphi neue Komponente?

Einzelnen Beitrag anzeigen

Daniel B
(Gast)

n/a Beiträge
 
#13
  Alt 1. Feb 2003, 21:23
Du bist schon a bisserl Faul?!
1. Suche benutzen, dies wurde schon sehr oft besprochen.
2. Sagt die OH folgendes dazu:
Delphi-Quellcode:
Indicates whether a given component is owned by the component.

function FindComponent(const AName: string): TComponent;

Description

FindComponent returns the component in the Components property array with the name that matches the string in the AName parameter. Use FindComponent to determine whether a given component is owned by another.
Delphi-Quellcode:
The following example creates 20 edit boxes, using FindComponent with the edit box name to access each newly created edit box.

procedure TForm1.Button1Click(Sender: TObject);

var
  i: Integer;
const
  NamePrefix = 'MyEdit';
begin
  for i := 1 to 20 do begin
    TEdit.Create(Self).Name := NamePrefix + IntToStr(i);
    with TEdit(FindComponent(NamePrefix + IntToStr(i))) do
    begin
      Left := 10;
      Top := i * 20;
      Parent := self;
    end;
  end;
end;
Grüsse, Daniel
  Mit Zitat antworten Zitat