1
If anyone can help me, I’m having a problem in a method of a ListView, the method is the TForm13.ListView1UpdateObjects in it I do the following procedure: I check the value of an item to decide whether or not to show an item and concateno the item to be shown.
Follows the code:
procedure TForm13.ListView1UpdateObjects(const Sender: TObject;
const AItem: TListViewItem);
var
ItemText_parcelar_cartao : TListItemText;
ItemText_valor_parc : TListItemText;
ItemText_quant_parc : TListItemText;
concat : TListItemText;
begin
ItemText_parcelar_cartao := AItem.Objects.FindObject('Text_parcelar_cartao') as TListItemText;
ItemText_valor_parc := AItem.Objects.FindObject('Text_valor_parcela') as TListItemText;
ItemText_quant_parc := AItem.Objects.FindObject('Text_quant_parcela') as TListItemText;
concat := AItem.Objects.FindObject('Text_concat') as TListItemText;
if ItemText_parcelar_cartao.text = 'sim' then
begin
concat.visible := true;
concat.text := 'ou ' + ItemText_quant_parc.text + 'x de ' + ItemText_valor_parc.text;
end
else
concat.visible := false;
end;
The problem is this: this ListView is connected in a FDMemTable main, when I charge FDMemTable with the data initially, everything works fine, and in another step I add more records to the FDMemTable main coming from a FDMemTable auxiliary, with the following function:
FDMemTable_produto_por_desc.AppendData(FDMemTable_produto_por_desc_pagina.Data, true);
When I add the new records, the function TForm13.ListView1UpdateObjects is executed, and it is at this time that the error occurs, the variable ItemText_parcelar_cartao.text is empty and does not receive the value of the FDMemTable, and therefore it does not test and does not concatenate correctly.
Cassiano, and if you try to play the text for a string variable, like this:
str := AItem.Objects.FindObject('Text_parcelar_cartao').asString;It would come the value correctly without having to move to a type variableTListItemText, but yes directly to astring?– Rodrigo Tognin
Or else
... AItem.Objects.FindObject('Text_parcelar_cartao').Text;. The idea is to find the object already picking the string located.– Rodrigo Tognin
Ok... Rodrigo, I did : str_parc := Tlistitemtext(Aitem.Objects.Findobject('Text_parcelar_cartao')). Text; yes . direct text does not work , but did not solve the problem, the variable remains empty.
– Cassiano Luz