如何在 Visual Basic 2005 中的水晶报表中将文本框值作为参数传递

问题描述:

Form1 有一个 button1 和一个 texbox1,当我点击 button1 时,form2 将加载水晶报告并显示我放在 textbox1 上的数据.已经创建了Parameters Field crTextBox 并放入了crystalreport.如何将 textbox1.text 值传递给 crTextBox.

Form1 has a button1 and a texbox1, when I click button1, form2 will load with crystal report on it and display data that I put on textbox1. Already created Parameters Field crTextBox and put into crystalreport. How can I pass textbox1.text value to crTextBox.

在Form2里面添加如下代码

Add the following code inside Form2

Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
    Dim Report1 As New CrystalReport1

    Report1.SetParameterValue("crTextBox", Form1.TextBox1.Text)
    CrystalReportViewer1.ReportSource = Report1
End Sub