Board index » delphi » How to make serveral components (drawed into form b4) into array form ?

How to make serveral components (drawed into form b4) into array form ?


2003-11-12 08:31:35 PM
delphi193
eg. button[1] , button[2] , etc...
i know how to dynamic make it , but how about the components is drawn
into the form previously ?
Deeply thanks for helping.
--
 
 

Re:How to make serveral components (drawed into form b4) into array form ?

OH MY God writes:
Quote
eg. button[1] , button[2] , etc...

i know how to dynamic make it , but how about the components is drawn
into the form previously ?
Just store a separate reference to the components. Dropping the
buttons onto the form will add a reference to the published section of
your form, like this:
type
TMyform = class(TForm)
Button1: TButton;
Button2: TButton;
...
private
public
end;
...you can add your own button array variable and store a duplicate
reference there:
type
TMyform = class(TForm)
Button1: TButton;
Button2: TButton;
...
private
FButtons: array[1..2] of TButton;
public
end;
implementation
procedure TMyForm.FormCreate(Sender: TObject);
begin
// add button references to array
FButtons[1] := Button1;
FButtons[2] := Button2;
end;
If the scope of the array is larger than the scope of the form (in
this case, it isn't, and I can not think of a good reason why it would
ever need to be), make sure to nil the references when the form is
destroyed.
-Craig
--
Craig Stuntz [TeamB] . Vertex Systems Corp. . Columbus, OH
Delphi/InterBase Weblog : delphi.weblogs.com
Please read and follow Borland's rules for the user of their
news server: info.borland.com/newsgroups/guide.html