Create some fields in runtime

Hi, I have a report with a Masterdata band and some fields in it. It works fine, however I create some field in runtime (based on the user preferences). I use the following code to create the frxMemoView:
  frmTitle,frmField : TfrxMemoView;
  frbTitle,frbMaster: TfrxBand;
  i : smallint;
  fLeft, fWidth : Double;
begin
  fLeft := 12;
  fWidth := 1.20;
  with NData,frxReporte do
  begin
    frbMaster := FindObject('frbMasterData') as TfrxMasterData;
    frbTitle := FindObject('frbColumnHeader') as TfrxColumnHeader;
    for i := cbMes1.ItemIndex to cbMes2.ItemIndex do
    begin
      frmTitle := TfrxMemoView.Create(frbTitle);
      frmtitle.CreateUniqueName;
      frmTitle.Text := cbMes1.Properties.Items[i];
      frmTitle.Font.Name :='Tahoma';
      frmTitle.Font.Size := 8;
      frmTitle.Font.Style := [fsBold];
      frmtitle.HAlign := haCenter;
      frmTitle.SetBounds(fLeft,0,fWidth,1.10);
      with TfrxMemoView.Create(frbMaster) do
      begin
        CreateUniqueName;
        SetBounds(fLeft,0,fWidth,0.5);
        Autowidth := true;
        DataSet := fdsDatos;
        DataField := cbMes1.Properties.Items[i];
        HAlign := haRight;
        Font.Size := 8;
        Font.Name := 'Tahoma';
        Frame.Typ := [ftLeft];
      end;
      fLeft := fLeft + fWidth;
    end;
  end;

But this code don't work, I can't see the objects created in the report.

Thank you in advance for your help

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 10:58AM
    your problem lies in the declartion of your variables.
    frbTitle,frbMaster: TfrxBand;
    the variable must be of the correct type.
    ie
    frbmaster should be of type tfrxmasterdata;
  • edited 10:58AM
    Thanks its work fine.

    Another issue is the position of the Objects. For example in designtime the left property has the value 8.1, but in runtime the same property has another value. Why? How can i set the correct values to positioning the object .(I am using the Setbounds method)

    Thanks in advance.

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.