各位高手,在VB.NET中如何調用含有子報表的水晶報表呀.好人呀.幫幫我!!

lijianhuaabcd 2005-03-18 04:59:05
各位高手,晚輩剛用水晶報表,現在要用VB.NET去調用一個帶有子報表的水日報表,試了很久都不行,
還請各位幫忙.
...全文
92 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
阿泰 2005-03-19
  • 打赏
  • 举报
回复
VB.Net

WinForm ,上面放一个CrystalReportViewer1

看起来比较痛苦,慢慢看吧,呵呵

如果我有时间的话来写个教程啥的 :)
阿泰 2005-03-19
  • 打赏
  • 举报
回复
'********************************************
'Created: January 17, 2002
'Author ID: JAS
'Purpose: This Visual Basic .NET sample Windows application demonstrates
' accessing a subreports (in a main report) at runtime.
'*********************************************

''Both of these CR assemblies are required to be able to
''access, load, and access subreports.
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class Form1
Inherits System.Windows.Forms.Form

''CR Variables
Dim crReportDocument As MainReport
Dim crSections As Sections
Dim crSection As Section
Dim crReportObjects As ReportObjects
Dim crReportObject As ReportObject
Dim crSubreportObject As SubreportObject
Dim crSubreportDocument As ReportDocument

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

''Create an instance of the strongly-typed MAIN report object
crReportDocument = New MainReport()

''Get all the sections in the report
crSections = crReportDocument.ReportDefinition.Sections

''Loop through each section of the report...
For Each crSection In crSections

''Get all the report objects from each section
crReportObjects = crSection.ReportObjects

''Loop through each report object...
For Each crReportObject In crReportObjects

''Check to see if the report object is a subreport
If crReportObject.Kind = ReportObjectKind.SubreportObject Then

''Found the subreport.
''Get the actual subreport object
crSubreportObject = CType(crReportObject, SubreportObject)

''Get the subreport as a regular report object.
''The OpenSubreport returns the subreport object as a report
crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName)

''Display the name of the subreport.
MessageBox.Show("Subreport Name: '" & crSubreportDocument.Name & "'")

End If
Next ''Go to the next report object
Next ''Go to the next section

''Set the viewer to the report object to be previewed.
CrystalReportViewer1.ReportSource = crReportDocument


End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
Friend WithEvents CrystalReportViewer1 As CrystalDecisions.Windows.Forms.CrystalReportViewer

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.CrystalReportViewer1 = New CrystalDecisions.Windows.Forms.CrystalReportViewer()
Me.SuspendLayout()
'
'CrystalReportViewer1
'
Me.CrystalReportViewer1.ActiveViewIndex = -1
Me.CrystalReportViewer1.Dock = System.Windows.Forms.DockStyle.Fill
Me.CrystalReportViewer1.Name = "CrystalReportViewer1"
Me.CrystalReportViewer1.ReportSource = Nothing
Me.CrystalReportViewer1.Size = New System.Drawing.Size(292, 273)
Me.CrystalReportViewer1.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 273)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.CrystalReportViewer1})
Me.Name = "Form1"
Me.Text = "Form1"
Me.ResumeLayout(False)

End Sub

#End Region

End Class

4,819

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 图表区
社区管理员
  • 图表区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧