Hi, I have a report with an image called 'OFERTA' and I want to show/hide depending on the 'Oferta' field on my query.
I've added BeforePrint event, that uses a TfrReport as Sender. I use the sender as report to find the image, check if <> nil and toggle visibility.
I've debugged the code, and yes frimg.Visible is True / False depending on the value of ('Oferta' = 'T').
Despite all being ok, the image is or always visible or always hidden, depending on how it was designed the report!
Help
procedure TfrmListProductos.frProductosBeforePrint(Sender: TfrReport);
var
frimg: TFRPictureView = nil;
begin
if Productos.FindField('bOferta') <> nil then // ok
begin
frimg:=TFRPictureView(Sender.FindObject('OFERTA')); // ok
if Assigned(frimg) then // ok
begin
frimg.Visible := (frDBDataSetProductos.DataSet.FieldByName('Oferta').AsString = 'T'); // this is ok
end;
end;
end;