hay algun comando para duplicar una ficha de una Tkbmemtable?
con table1.insert añado
con table2.delete borro
existe algun comando tipo table1.duplicate para duplicar la ficha seleccionada
¿o tengo que hacerlo a mano?
he encontrado esta funcion pero no me funciona bien, no se porque me quedan campos sin copiar, uso delphi 2010.
Código PHP:
procedure DuplicateCurrentRecord(aDataSet : TDataSet);
var
Data : array of variant;
aRecord : array of TVarRec;
i : integer;
max : integer;
begin
max := aDataSet.fields.count -1;
// set the lenghth of the arecord array to be the same as the number of
// elements in the data array
SetLength(arecord,max+1);
SetLength(data,max+1);
// set the variant type pointers to the data array
for i := 0 to max do
begin
arecord[i].VType := vtVariant;
arecord[i].VVariant := @data[i];
end;
// Copy the Record to the Array
for i := 0 to max do
Data[i] := aDataSet.fields[i].value;
// finally append the record in one go
aDataSet.AppendRecord(aRecord);
end;
lo he pasado para que funcione con kbmemtable pero como digo no me duplica todos los campos de las fichas,
los demas los deja en blanco, es raro porque a veces me duplica los dos primeros, otras veces los tres primeros....
Código PHP:
procedure DuplicateCurrentRecord(aDataSet : TkbmMemTable);
var
Data : array of variant;
aRecord : array of TVarRec;
i : integer;
max : integer;
begin
max := aDataSet.RecordCount -1;
// set the lenghth of the arecord array to be the same as the number of
// elements in the data array
SetLength(arecord,max+1);
SetLength(data,max+1);
// set the variant type pointers to the data array
for i := 0 to max do
begin
arecord[i].VType := vtVariant;
arecord[i].VVariant := @data[i];
end;
// Copy the Record to the Array
for i := 0 to max do
Data[i] := aDataSet.fields[i].value;
// finally append the record in one go
aDataSet.AppendRecord(aRecord);
end;