[英](TSQLConnection) Why are the Left and Top properties only available in the .dfm file?
I'm just curious why you can drop a TSQLConnection
on a form and it will add Left
and Top
properties to the .dfm
: 我很好奇为什么可以在窗体上放置
TSQLConnection
,它将在.dfm
添加Left
和Top
属性:
object Form1: TForm1
...
object SQLConnection1: TSQLConnection
Left = 8
Top = 8
end
end
But when you create it in code, the Left
and Top
properties are not members of the TSQLConnection
class: 但是,当您在代码中创建它时,
Left
和Top
属性不是TSQLConnection
类的成员:
interface
type
TForm1 = class(TForm)
SQLConnection1: TSQLConnection;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FSQLCon: TSQLConnection;
public
{ Public declarations }
end;
implementation
procedure TForm1.FormCreate(Sender: TObject);
begin
FSQLCon := TSQLConnection.Create(Self);
FSQLCon.Left := 280;
FSQLCon.Top := 200;
end;
Compile: 编译:
[DCC Error] Unit1.pas(30): E2003 Undeclared identifier: 'Left'
[DCC Error] Unit1.pas(31): E2003 Undeclared identifier: 'Top'
Why are some properties only available for assignment in the .dfm
? 为什么某些属性只能在
.dfm
分配? Shouldn't you be able to assign all properties in code ( .pas
) that are set in the form ( .dfm
)? 您是否不能以代码(
.dfm
)设置的代码( .pas
)中分配所有属性?
FYI - Using Delphi XE2 (Update 3) 仅供参考-使用Delphi XE2(更新3)
The properties Left
and Top
for TComponent do not exist really. TComponent的
Left
和Top
属性实际上并不存在。 The are set for the designer in DefineProperties used by ReadProperty
and WriteProperties
. 的设置是由
ReadProperty
和WriteProperties
使用的DefineProperties中的设计器设置的。
Take a look at classes.pas. 看一下classes.pas。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.