RepeatUntil
RepeatUntil

Reputation: 2330

Delphi - Create component at runtime

how i can create component at runtime without declare a name of it in the variables

like

  for i := 0 to x do
  lHTTP[i] := TIdHTTP.Create(nil);

Is it possible to declare a variable at run time ?

Upvotes: 0

Views: 495

Answers (1)

Ast Pace
Ast Pace

Reputation: 152

One way or another, your component will have to be declared. It looks like you want to create an array of components, so you could declare the components as members of an array and then create them exactly as in your example.

var
  lHTTP: array of TIdHTTP;

and of course you would need to set the length of the array before creating your first component, e.g.

setlength(lHTTP, 10);

Upvotes: 1

Related Questions