Crystal Report + VB.NET 最基本顯示 (無連結 Database)

 

   Crystal Report + VB.NET 最基本顯示 (無連結 Database)
 
   基本條件:

  •    需要係 Project 上有一個 Crystal Report Item (有無連結 Database 無所謂)
  •    係 Windows Form 上要建立一個 Crystal Report Viewer – CrystalReportViewer1
     
 
   Imports CrystalDecisions.CrystalReports.Engine
 
   Public Class Form1
 
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
         Dim cr As New ReportDocument
         cr.Load("C:\Inetpub\web\pro1\WindowsApplication2\WindowsApplication2\1.rpt")
         CrystalReportViewer1.ReportSource = cr
         CrystalReportViewer1.Refresh()
         CrystalReportViewer1.Visible = False
      End Sub
 
      Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
         CrystalReportViewer1.Visible = True
      End Sub
 
   End Class