我正在使用VS 2010 - Visual Basic。 我在Report Viewer中报告了主报告:Report1.rdlc,然后是其他4个报告(也是rdlc文件),我打算在主报告中使用它作为子报告(Report2.rdlc,Report3.rdlc,Report4.rdlc和Report5.rdlc)
我现在遇到的问题是如何根据软件的请求动态添加或删除子报告?
我知道如何在rdlc文件上放置一个对象子报表后确定子报表,右键单击 - 子报表属性 - “将此报表用作子报表”。 但我必须从软件中做到这一点,因为有时Report3.rdlc必须是第一个子报告或Report4.rdlc。 Report2.rdlc不会每次都是第一个子报告。
我遇到的第二个问题是如何动态更改rdlc文件的大小 - 主报表(Report1.rdlc): 有时候只会有一个子报告,有时候只有两个子报告,有时只有两个。我不想有空白空间。
这可能吗?
如果是,有人可以提供示例代码吗?
非常感谢您的帮助。
最好的问候。
答案 0 :(得分:0)
Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
' Load the main report definition
Me.C1WebReport1.Report.ReportDefinition = Me.C1Report1.ReportDefinition
' OR you could load it this way:
' Me.C1WebReport1.Report = Me.C1Report1
' Now insert the subreport.
Dim f As C1.C1Report.Field = Me.C1WebReport1.Report.Fields("subreportHolder")
f.Subreport = Me.C1Report2
' Set the subreport field's Text property to act as a filter
f.Text = """CategoryID = "" & CategoryID"
' Optionally, hide the subreport header
f.Subreport.Sections.Header.Visible = False
End Sub
你可以参考this LInk