小编boo*_*tic的帖子

如何使用RTTI在Delphi中获取访问字段?

考虑以下:

TFieldType = class
  fValue: string;
end;

TMainClass = class
private
  Ffield: TFieldType;
public
  function GetValue: string;
end;
Run Code Online (Sandbox Code Playgroud)

在TMainClass.GetValue中,我试着获取TMainClass字段的值:

function TMainClass.GetValue;
begin
  vCtx := TRTTIContext.Create;
  vType := vCtx.GetType(Self.ClassInfo);
  for vField in vType.GetFields do
    vField.GetValue(
        //Here's the trouble, because i don't know how to get the instance
    );
Run Code Online (Sandbox Code Playgroud)

可能有另一种获取字段值的方法,这些字段是另一个类的实例?

delphi field rtti delphi-2010

6
推荐指数
1
解决办法
3274
查看次数

Delphi中的TOpenDialog - 如何只打开具有给定名称的文件

用户应该只打开"KLADR.DBF"文件.我将"Filter"属性设置为"kladr.dbf",对话框仅显示所需文件,但在同一目录中还有另一个".DBF"文件(STREET.DBF),用户可以通过在""中键入其名称来打开它.文件名:"编辑框.如何防止这种情况并让用户只选择所需的"KLADR.DBF"文件?

delphi topendialog

1
推荐指数
1
解决办法
975
查看次数

标签 统计

delphi ×2

delphi-2010 ×1

field ×1

rtti ×1

topendialog ×1