How to programmatically add a subreport into main report

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I can add a subreport into the main report at the develop time (visual way),
and everything works fine. However, I'd like to know how to do the same task
at the run time, ie, when the main report is loading, the second report is
adding into it.

Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want to
know how to link them together.

I will approciate if somebody can help me.
 
Hi Li,

We need to write the following code to add the controls dynamically :


START CODE

Dim myLabel As New DataDynamics.ActiveReports.Label()

myLabel.Text = "Test"

myLabel.Name = "Label1"

myLabel.Width = rpt.PrintWidth

myLabel.Top = 0

myLabel.Left = 0

myLabel.Height = 1

myLabel.Style = "text-align: center; font-weight: bold; font-size: 72pt;"

rpt.Sections("Detail").Controls.Add(myLabel)



END CODE



We need to add teh following code in order to add a section dynamically :



START CODE



With rpt.Sections
.Add(SectionType.PageHeader, "PageHeader")
.Add(SectionType.Detail, "Detail")
.Add(SectionType.PageFooter, "PageFooter")
End With



END CODE



Hope thsi helps.



Regards,

Mona [Grapecity]
 
Hi Mona,

Thanks for your response. However, I can't see any codes concerning to link
two existing reports.

Mona said:
Hi Li,

We need to write the following code to add the controls dynamically :


START CODE

Dim myLabel As New DataDynamics.ActiveReports.Label()

myLabel.Text = "Test"

myLabel.Name = "Label1"

myLabel.Width = rpt.PrintWidth

myLabel.Top = 0

myLabel.Left = 0

myLabel.Height = 1

myLabel.Style = "text-align: center; font-weight: bold; font-size: 72pt;"

rpt.Sections("Detail").Controls.Add(myLabel)



END CODE



We need to add teh following code in order to add a section dynamically :



START CODE



With rpt.Sections
.Add(SectionType.PageHeader, "PageHeader")
.Add(SectionType.Detail, "Detail")
.Add(SectionType.PageFooter, "PageFooter")
End With



END CODE



Hope thsi helps.



Regards,

Mona [Grapecity]

Li Pang said:
Hi,

I can add a subreport into the main report at the develop time (visual way),
and everything works fine. However, I'd like to know how to do the same task
at the run time, ie, when the main report is loading, the second report is
adding into it.

Both reports 'main.rpt', and 'subreport.rpt' are predefined, I only want to
know how to link them together.

I will approciate if somebody can help me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top