Unfortunately there is no way to do this, at least not natively.
The idea I had to try to get around this was to save the data in a list of strings ( StringList
) into a global variable.
Update
Do the following:
{ Declare na cláusula Uses as units StrUtils e Types }
var
Form1: TForm1;
StringList: TStringList; // Variável global
{
Procedimento responsável por carregar os itens salvos da StringList em um
Listview declarado por você.
}
procedure ListViewLoadItems(Listview: TListView);
var
I, J: Integer;
Fields: TStringDynArray; { Na seção Uses declare System.StrUtils e System.Types }
Item: TListItem;
begin
try
ListView.Clear;
for i := 0 to StringList.Count-1 do begin
Fields := SplitString(StringList[i], #9);
Item := Listview.Items.Add;
Item.Caption := Fields[0];
for j := 1 to high(Fields) do Item.SubItems.Add(Fields[j]);
end;
finally
StringList.Free;
end;
end;
{
Procedimento responsável por salvar os itens na StringList.
NOTA: Só será salvo os itens em que o SubItem[4] não conter a sequência
""OK""
}
procedure ListViewSaveItems;
procedure AddTextToLine(var Line: string; const Text: string);
begin
Line := Line + Text + #9;
end;
procedure MoveCompletedLineToList(const Strings: TStringList; var Line: string);
begin
Strings.Add(Copy(Line, 1, Length(Line)-1));
Line := '';
end;
Var
Tempstr: string;
I, J: Integer;
begin
StringList := TStringList.Create;
Tempstr := '';
try
for i := 0 to ListView1.Items.Count -1 do
if (ListView1.Items.Item[i] <> nil) and
(not ListView1.Items.Item[i].SubItems[4].Equals('OK')) then begin
AddTextToLine(Tempstr, ListView1.Items[i].Caption);
for j := 0 to ListView1.Items[i].SubItems.Count -1 do begin
AddTextToLine(Tempstr, ListView1.Items[i].SubItems[j]);
end;
MoveCompletedLineToList(StringList, Tempstr);
end;
except
// ....
end;
end;
This code has been adapted to your situation from that response in SOEn . To use just put two buttons and call the procedures, see an example:
Save the items:
procedure TForm1.BtnSaveitemsClick(Sender: TObject);
begin
ListViewSaveItems; // Salvará os itens
end;
Upload saved items to another Listview
:
procedure TForm1.BtnLoadItemsClick(Sender: TObject);
begin
if StringList = nil then exit; // Verifica se StringList é válido
ListViewLoadItems(ListView2); // Carrega os itens salvos na *Listview2*
end;
See this illustration:
ByclickingontheSave
button,theitemsthatdonotcontainSubItem4theOKwillbesaved.
NowwhenyouclicktheLoad
button,somethinglikethiswillappear:
This should work for you.