As follows:
The implementation part of the code is as follows:
var rec:integer = 0; Record Add-line button clicks implementation{$R *.dfm}//dynamically releases a single component memory, which destroys the component procedure Tform1.deleterow (sender:tobject); Begin If rec < 1 then Exit else begin Tpanel (Panel1.controls[rec]). Free; Frees a single control memory Tcombobox (Panel2.controls[rec]). Free; Tedit (Panel3.controls[rec]). Free; DEC (REC); Increment the number of buttons end;end;//dynamically create a single component procedure Tform1.addrow (sender:tobject); var e:integer; Record the total number of current components Edt:tedit; Pnl:tpanel; Combo:tcombobox;begin INC (rec); Number of button clicks e: = Panel3.controlcount; Edit number //Dynamic Create edit EDT: = Tedit.create (PANEL3); EDT. Parent: = Panel3; EDT. Left: = Edit1.left; EDT. Top: = Edit1.top + (edit1.height + 3) *e; EDT. Width: =edit1.width; EDT. Height: = edit1.height; EDT. Text: = ' Edit ' + inttostr (rec + 1); EDT. Show; Panel, ComboBox creation method and edit the same end;
Delphi dynamic creation of components, single creation, single destruction