Interface
USES the
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls ExtCtrls ComCtrls;
Type
TForm1=class (TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
For: TButton;
Button2: TButton;
Procedure Button1Click (Sender: TObject);
Procedure Button2Click (Sender: TObject);
Private
{Private declarations}
Public
{Public declarations}
end;
Var
Form1: TForm1;
Sp1: tshape;
Implementation
{$R *. DFM}
Procedure TForm1. Button1Click (Sender: TObject);
The begin
Sp1:=tshape. Create (nil);
Sp1. Parent:=form1. PageControl1. Pages [0].
Sp1. Name:='aaaa';
end;
Procedure TForm1. Button2Click (Sender: TObject);
Var sp1: tshape;
The begin
Tshape (form1. PageControl1. Pages [0]. FindChildControl (" aaaa ")). Destroy;
//sp1. Destroy;
end;
End.
Click for the dynamically generated a tshape, click delete the tshape always make mistake when button2 ~ ~ how to achieve??
Trouble masters action you ~ ~ ~ ~ such as online
CodePudding user response:
Supplement: is how to according to create the NAME to delete this control ~ ~CodePudding user response:
Control name. Not freeCodePudding user response:
FindChildControl can only find TWinControl and its subclasses, TShape not TWinControl subclasses, find out is nil, and of course, anCan use PageControl1. Pages [0]. Controls [] traversal
CodePudding user response: