How to find all Memos in Report with a given TagStr using PascalScript

How can I find (and update) all Memos with a given TagStr in the report using PascalScript?


Using the following Code only Memos in the same band as the sender are found:


procedure Memo42OnPreviewClick(Sender: TfrxView; Button: TMouseButton; Shift: Integer; var Modified: Boolean);

 var

   p: TfrxComponent;

   i: Integer;

begin

   p := Sender.Parent;       

   if p = nil then Exit;

   for i := 0 to p.Objects.Count - 1 do

   if (p.Objects[i] is TfrxMemoView) and (TfrxMemoView(p.Objects[i]).TagStr = 'Something') then

   begin

     TfrxMemoView(p.Objects[i]).Text := 'Hello World!';

     Report.Preview.Invalidate;

   end;

end;

Comments

  • By using

    p := Sender.parent.parent

    I get the TfrxReportPage object, but using this will only find all the object of the reports page.


    Now I'm stuck at getting all the report pages and there objects, any clues?

  • Ok, got it.

    Loop through all preview pages and their objects:

            for i := 0 to PreviewPages.Count-1 do
              begin
                page := PreviewPages.Page[i];
                for j := 0 to page.AllObjects.Count - 1 do
                 begin
                 // search for object with tag
                 c := page.AllObjects[j];
                 if (c is TfrxCheckboxView) then
                   begin
                     if (TfrxCheckboxView(c).TagStr = tag) then
                       begin
                           // if found: update its value with 'value'
                         TfrxCheckboxView(c).Checked := StrToBool(value);
                         PreviewPages.ModifyObject(TfrxComponent(c));
                       end;
                    end;
                   end;
                 end;  
    

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.