By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,571 Members | 960 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,571 IT Pros & Developers. It's quick & easy.

How to programmatically add a subreport into main report

P: n/a
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.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
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" <Li****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
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.

Nov 21 '05 #2

P: n/a
Hi Mona,

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

"Mona" wrote:
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" <Li****@discussions.microsoft.com> wrote in message
news:2E**********************************@microsof t.com...
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.


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.