Home > Back-end >  Delphi dynamically created controls
Delphi dynamically created controls

Time:10-15

Now I wrote it to dynamically create the TIMage control also double-click event but I want to get this in double time the name of the Image element
How can I write

CodePudding user response:

Var
S_name: string;
The begin
If the sender is Timage then s_name:=Timage (sender). The name;
end

CodePudding user response:

reference 1st floor superlixiao78 response:
var
S_name: string;
The begin
If the sender is Timage then s_name:=Timage (sender). The name;
End

Showmessage is empty

CodePudding user response:

CodePudding user response:

(sender as Tbutton). The name

CodePudding user response:

The
reference 4 floor dobetterthatnthink reply:
(sender as Tbutton). The name

Should be, didn't give you to create name attribute, which is written

CodePudding user response:

With LS, created to give it a name
 
Var
Img: Timage;
The begin
Img:=TImage. Create (Self);
Img. Name:='myImg';
.

CodePudding user response:

refer to the second floor q296361388 response:
Quote: refer to 1st floor superlixiao78 response:

Var
S_name: string;
The begin
If the sender is Timage then s_name:=Timage (sender). The name;
End

Showmessage is empty


It ought to be you didn't name this component is created, upstairs, name code when creating,

CodePudding user response:

Look at yourself when create timgage control problem

CodePudding user response:

When creating a TIMage, given name attribute to the image, add a tag
 
SetLength (image, 4);
.
Image: [I]=TImage. Create (Self);
Image [I]. Caption:='open';
Image [I]. Name:='Name' + inttostr (I);
Tag image [I]=I;
Top image [I]=Top;
Left image [I]=Left;
Image [I] : OnClick=ClickImage;
.

In the event of an image ClickImage click
 
If the sender is TImage then
The begin
I:=(sender as TImage). The tag;
Showmessage (image [I] name);
end;

CodePudding user response:

CodePudding user response:

Controls the name just in writing the code used to obtain control object, and dynamically created controls have direct access to the object, the name has no meaning,

CodePudding user response:

Upstairs said identity I normally use the built dynamic array to record the dynamic object, 9/f, the classmates have given unless you want to use the name of course is solution of 6th floor
  • Related