考虑以下:
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)
可能有另一种获取字段值的方法,这些字段是另一个类的实例?
用户应该只打开"KLADR.DBF"文件.我将"Filter"属性设置为"kladr.dbf",对话框仅显示所需文件,但在同一目录中还有另一个".DBF"文件(STREET.DBF),用户可以通过在""中键入其名称来打开它.文件名:"编辑框.如何防止这种情况并让用户只选择所需的"KLADR.DBF"文件?