Delphi dynamic creation of components, single creation, single destruction

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.