Unfortunately there is no way to do this, at least not natively.
The idea I had to work around this was to save the data in a list of strings(StringList
) in a global variable.
Updating
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;
That code has been adapted for your situation from of that reply in Soen. To use just put two buttons and call the procedures, see an example:
Save items:
procedure TForm1.BtnSaveitemsClick(Sender: TObject);
begin
ListViewSaveItems; // Salvará os itens
end;
Load saved items into 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:
By clicking the button Save
items that do not contain in your Subitem 4 the word OK will be saved.
Now by clicking the button Load
will be shown something like this:
This should work for you.
Thanks for the reply friend, I’m actually breaking my head here.... I couldn’t think of anything. Imagine the following, I have a LISTVIEW with 3 COLUMNS, in this LISTVIEW insert several records.... When the REGISTRATION is COMPLETED I use the BUTTON to update the same and put a "OK" in front. I need to have another BUTTON, when I click it, it "hide" the LOGS without the "OK" and show only the ones with the "OK" I could understand?
– user7605