Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Delphi 在嵌入式TFrame中访问组件属性_Delphi_Frames_Rtti - Fatal编程技术网

Delphi 在嵌入式TFrame中访问组件属性

Delphi 在嵌入式TFrame中访问组件属性,delphi,frames,rtti,Delphi,Frames,Rtti,我有一个带有嵌入式TFrame的表单,其中一些组件(父表单和框架中的组件)具有相关属性。我可以使用以下方式访问父窗体组件属性: for field in ctx.GetType(frm.ClassInfo).GetFields do for attr in field.GetAttributes do... 我尝试使用以下嵌套在主循环中的方法访问帧中的属性: for subField in ctx.GetType(field.ClassInfo).GetFields do for at

我有一个带有嵌入式TFrame的表单,其中一些组件(父表单和框架中的组件)具有相关属性。我可以使用以下方式访问父窗体组件属性:

for field in ctx.GetType(frm.ClassInfo).GetFields do
  for attr in field.GetAttributes do...
我尝试使用以下嵌套在主循环中的方法访问帧中的属性:

for subField in ctx.GetType(field.ClassInfo).GetFields do
  for attr in subField.GetAttributes do...

但是,这无法拾取帧的组件作为字段,当然也无法拾取相关属性。是否可以访问嵌入式框架的组件属性?我使用的是XE7。

您所做的是请求
TRttiInstanceField
的字段(这是字段变量上的
ClassInfo
将提供给您的)

正确的做法是使用
FieldType
属性:

for subField in field.FieldType.GetFields do
  for attr in subField.GetAttributes do...

这是在对框架中的控件进行仿冒绑定实验时出现的。到目前为止,它看起来还不错——我过去使用过KnockoutJS,而您出色的仿制品正是我为Delphi所需要的。