component 与control有什么区别?

2025-03-26 20:36:59
推荐回答(3个)
回答1:

控件是可视的, 组件包含控件。。。。 delphi对控件是有parent 关系的. 你可看一看: Label1.caption:=inttostr(self.ComponentCount );Edit1.text:=inttostr(self.ControlCount); 的结果....... 可能对你有帮助.

回答2:

不好意思,上面是错的,我少放了一个panel1,加上去后再测结果为:component是5control是0

回答3:

unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Panel1: TPanel; Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);beginEdit1.Text:=inttostr((Sender as TWincontrol).Parent.ControlCount);Edit2.Text:=inttostr( TWinControl(Sender).Parent.ComponentCount);end;end.