about frxComponent access by index or similar

edited June 2007 in FastReport 4.0
Hello:

I need optimized my code into the frx file, not in delhi code, so in this moment to developer use this code, i repeat in the code into frx file:
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
begin
  If( ( DayOfWeek( StrToDate(<Date01>) ) = 1) or
      ( DayOfWeek( StrToDate(<Date01>) ) = 7) ) then
  begin
       Memo11.Color := clRed;
       Memo42.Color := clRed;
       Memo73.Color := clRed;           
  end
  else
  begin
       Memo11.Color := clWhite;
       Memo42.Color := clWhite;
       Memo73.Color := clWhite;           
  end;
  If( ( DayOfWeek( StrToDate(<Date02>) ) = 1) or
      ( DayOfWeek( StrToDate(<Date02>) ) = 7) ) then

  begin
       Memo12.Color := clRed;
       Memo43.Color := clRed;
       Memo74.Color := clRed;           
  end
  else
  begin
       Memo12.Color := clWhite;
       Memo43.Color := clWhite;
       Memo74.Color := clWhite;           
  end;

  If( ( DayOfWeek( StrToDate(<Date03>) ) = 1) or
      ( DayOfWeek( StrToDate(<Date03>) ) = 7) ) then

  begin
       Memo13.Color := clRed;
       Memo44.Color := clRed;
       Memo75.Color := clRed;           
  end
  else
  begin
       Memo13.Color := clWhite;
       Memo44.Color := clWhite;
       Memo75.Color := clWhite;           
  end;

.....
...
..

  If( ( DayOfWeek( StrToDate(<Date31>) ) = 1) or
      ( DayOfWeek( StrToDate(<Date31>) ) = 7) ) then

  begin
       Memo42.Color := clRed;
       Memo73.Color := clRed;
       Memo104.Color := clRed;           
  end
  else
  begin
       Memo42.Color := clWhite;
       Memo73.Color := clWhite;
       Memo104.Color := clWhite;           
  end;

end;

so I wil prefer something so:
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);

var i:Integer

begin

   for i := 1 to 31 do
   begin
      If( ( DayOfWeek( StrToDate(frxComponent.index[i]) ) = 1) or
       ( DayOfWeek( StrToDate(frxComponent.index[i]) ) = 7) ) then
      begin
       frxComponent.index[i+31].Color := clRed;
       frxComponent.index[i+62].Color := clRed;
       frxComponent.index[i+93].Color := clRed;
      end
      else
      begin
       frxComponent.index[i+31].Color := clWhite;
       frxComponent.index[i+62].Color := clWhite;
       frxComponent.index[i+93].Color := clWhite;
       end;
   end;
end;

but the reporter show error, so i think that this is because I do not how reference to frxComponet, in this case frxMem, for it index

Exists another metoht fot this correct???

thanks

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 8:28PM
    how to iterate through the objects of a band in band's obp event example

    var
    i: Integer;
    c: TObject;

    for i := 0 to Sender.Objects.Count - 1 do
    begin
    c := Sender.Objects
    if c is TfrxMemoView then
    TfrxMemoView©.Visible := False// or whatever prop you want to set
    else if c is TfrxLineView then
    TfrxLineView©.Visible := True
    end;

  • edited 8:28PM
    thanks for your help, all correct

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.