Estimado le propongo la siguiente opción.
Código Delphi
[-]
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Grids, Vcl.ValEdit, Vcl.StdCtrls;
type
TDatos=record
FieldName:String;
FieldValue:String;
end;
TDatosList=TArray;
TForm1 = class(TForm)
Button1: TButton;
vlData: TValueListEditor;
procedure Button1Click(Sender: TObject);
private
public
function GetDatos(AFields:Array Of String): TDatosList;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
Var
Datos:TDatosList;
i: Integer;
begin
Datos:=GetDatos(['Campo 1','Campo 2','Campo3']);
for i := Low(Datos) to High(Datos) do
vlData.Values[Datos[i].FieldName]:=Datos[i].FieldValue;
SetLength(Datos,0);
end;
function TForm1.GetDatos(AFields:Array Of String): TDatosList;
var
i:Integer;
begin
SetLength(result,length(AFields));
for i := Low(AFields) to High(AFields) do
begin
result[i].FieldName := AFields[i];
result[i].FieldValue:= 'Valor de '+AFields[i];
end;
end;
end.
Saludos cordiales