FastReports how to generate a master-detail report in code
Posted on 2011-10-17
Fast Reports Inc. home siteRulesHelpSearchMembersCalendar
Search this forum only? More Search Options [X]My Assistant
Loading. Please Wait...
Site Message (Message will auto close in 2 seconds)
Logged in as: BatteryPack ( Log Out )
My Controls · View New Posts · My Assistant · My Friends · 0 New Messages
Fast Reports forum > Fast Reports Products > FastReport 4.0
Master-Detail using Code, How do you create a Master-Detail in code Options Track this topic Email this topic Print this topic Download this topic Subscribe to this forum Display Modes Switch to: Outline Standard Switch to: Linear+
View Member Profile Add as Friend Send Message Find Member's Topics Find Member's Posts Today, 03:33 AM Post #1
Joined: 14-October 11
Member No.: 54120
I am trying out the demo software, and am most impressed with FastReport.
However, I have run into a fundamental problem for which there seems to be no documentation whatsoever.
I need to generate master-detail reports in code.
My example is a small school consisting of 3 teachers, each having 3 pupils.
All data comes from simple xml, and SQL is not used anywhere.
<?xml version="1.0" encoding="utf-8"?>
I generate a schema which produces a typed dataset.
I proceed as follows.
public partial class Form1 : Form
public school School;
public school.teacherDataTable Teachers;
public school.pupilDataTable Pupils;
School = new school();
Teachers = new school.teacherDataTable();
Pupils = new school.pupilDataTable();
I then try to generate a FasReport as follows:
private void btnLoad_Click(object sender, EventArgs e)
Report report = new Report();
report.GetDataSource("teacher").Enabled = true;
ReportPage page1 = new ReportPage();
page1.Name = "Page1";
page1.ReportTitle = new ReportTitleBand();
page1.ReportTitle.Name = "ReportTitle1";
page1.ReportTitle.Height = Units.Millimeters * 15f;
TextObject SchoolTitleText = new TextObject();
SchoolTitleText.Name = "SchoolTitle";
SchoolTitleText.Bounds = new RectangleF(0, 0,
Units.Centimeters * 19, Units.Centimeters * 1);
SchoolTitleText.Text = "NorthDale School";
SchoolTitleText.HorzAlign = HorzAlign.Left;
SchoolTitleText.Font = new Font("Tahoma", 14, FontStyle.Bold);
GroupHeaderBand group1 = new GroupHeaderBand();
group1.Name = "GroupHeader1";
group1.Height = Units.Centimeters * 1;
group1.Condition = "[teacher.TeacherName]";
group1.GroupFooter = new GroupFooterBand();
group1.GroupFooter.Name = "GroupFooter1";
group1.GroupFooter.Height = Units.Millimeters * 5;
DataBand databand1 = new DataBand();
databand1.Name = "Data1";
databand1.Height = Units.Centimeters * 0.5f;
databand1.DataSource = report.GetDataSource("teacher");
group1.Data = databand1;
TextObject TeacherText = new TextObject();
TeacherText.Name = "TeacherText";
TeacherText.Bounds = new RectangleF(0, 0, Units.Millimeters * 59, Units.Millimeters * 7f);
TeacherText.Text = "[teacher.TeacherName]";
TeacherText.Font = new Font("Tahoma", 11, FontStyle.Bold);
DataBand Databand2 = new DataBand();
Databand2.Name = "Data2";
Databand2.Height = Units.Centimeters * 0.5f;
Databand2.DataSource = report.GetDataSource("pupil");
TextObject PupilText = new TextObject();
PupilText.Name = "PupilText";
PupilText.Bounds = new RectangleF(0, 0, Units.Millimeters * 59, Units.Millimeters * 7f);
PupilText.Text = "[pupil.Name]";
PupilText.Font = new Font("Tahoma", 10, FontStyle.Regular);
The report correctly lists the 3 teacters, but each teacher has all 9 pupils intead of 3.
I have hunted high and low for any documentation on how to create the master-detail relationships using code, but amazingly, there does not seem to be any.
The basic PDF deals only with a simple list, and the downloadable Net documentation is devoid of any guidance at all.
I would be most obliged if someone can assist me with this very fundamental task, so that I can go ahead and buy the software.