Cannot create three separate bands in a report.

I am trying to implement a simple FastReport example in Embarcadero RAD Studio XE5/C++Builder that holds a basic table as its dataset and outputs a report with three pieces: a header band (that will display the title of the report), a column header band (that will display the field names of the fields in the dataset), and a data band (that will display the data itself). My problem is the databand is covering the entirety of the report. Why won't the titleband and columnheaderband get displayed? My code is as follows:
// ADODataSet1 contains the employee.db table
try
{
    ADODataSet1->Open();
}
catch(Exception& e)
{
    LogIt("ERROR: Could not open ADODataSet1: '" + e.Message + "'");
    return;
}

TfrxReport* frxReport1 = new TfrxReport(this);

TfrxDBDataset* frxDBDataset1 = new TfrxDBDataset(this);

frxReport1->Clear();
frxReport1->DataSets->Add(frxDBDataset1);
frxDBDataset1->DataSet = ADODataSet1;

TfrxDataPage* DataPage = new TfrxDataPage(frxReport1);
TfrxReportPage* Page = new TfrxReportPage(frxReport1);

Page->CreateUniqueName();

// set sizes of fields, paper and orientation to defaults
Page->SetDefaults();

TfrxReportTitle* HeaderBand = new TfrxReportTitle(Page);
HeaderBand->CreateUniqueName();
HeaderBand->Top = 0;
HeaderBand->Height = 20;

TfrxMemoView* Memo = new TfrxMemoView(HeaderBand);
Memo->CreateUniqueName();
Memo->Text = "Report of Employee Table";
Memo->Height = 20;

TfrxBand* ColumnHeaderBand = new TfrxBand(Page);
ColumnHeaderBand->CreateUniqueName();
ColumnHeaderBand->Top = HeaderBand->Top + HeaderBand->Height;

TfrxMasterData* DataBand = new TfrxMasterData(Page);
DataBand->CreateUniqueName();
DataBand->DataSet = frxDBDataset1;

DataBand->Top = ColumnHeaderBand->Top + ColumnHeaderBand->Height;
DataBand->Height = 20;

TfrxMemoView* mField;
for (int i = 0; i < ADODataSet1->FieldCount; ++i)
{
    // Take care of the field names in the column header first
    mField = new TfrxMemoView(ColumnHeaderBand);
    mField->CreateUniqueName();
    mField->SetBounds(i * 100, 0, 100, 20);
    mField->Text = ADODataSet1->Fields->Fields[i]->FieldName;
    mField->HAlign = haCenter;

    // Now do the actual data
    mField = new TfrxMemoView(DataBand);
    mField->CreateUniqueName();
    mField->DataSet = frxDBDataset1;
    mField->DataField = ADODataSet1->Fields->Fields[i]->FieldName;
    mField->SetBounds(i * 100, 0, 100, 20);
    mField->HAlign = haRight;
}

// show report
frxReport1->ShowReport(true);

frxReport1->SaveToFile("C:\\temp\\employee.fr3");

return;

I am making sure that the Top properties of HeaderBand, ColumnHeaderBand, and DataBand all contain enough room for their Height, so why when I run this code do I only see DataBand on my report?

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 2:26PM
    have you tried the example in the programmers manual?
  • edited 2:26PM
    gordk wrote: »
    have you tried the example in the programmers manual?


    Yeah, that's what I originally based my code off of. I figured out the solution: I never explicitly set the Width of the Memo component.
    I needed to add the line with the comment below:
    TfrxMemoView* Memo = new TfrxMemoView(HeaderBand);
    Memo->CreateUniqueName();
    Memo->Text = "Report of Employee Table";
    Memo->Height = 20;
    Memo->Width = 200; // This line needed to be added.
    
    TfrxBand* ColumnHeaderBand = new TfrxBand(Page);
    

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.