你說的是想傳一個子段碼,在報表裡面動態顯示碼,
你可以在你拿數據的類裡面定義 一個函數來傳參數
比如
istg_Name as string
Public Sub SetName(ByVal astg_Name As String)
Me.istg_Name = astg_Name
End Sub
Public Function GetName() As String
Return Me.istg_Name
End Function
然後在你觸發報表的事件代碼哪裡加上這些就可以了
abc as class aa 'aa是你的哪個類名
然後把lrpt_customer.SetParameterValue("name", "你想要傳的字符")
改成這樣就可以了
lrpt_customer.SetParameterValue("name", abc.GetName)
Dim lrpt_customer As New Report_customer
'Report_customer 是你的報表名稱
lrpt_customer.SetParameterValue("name", "你想要傳的字符")
lrpt_customer.SetDataSource(ldtb_customer_result)
'ldtb_customer_result 是給你報表傳的數據
Dim lfrm_customer As New Form_customer_Report
'Form_customer_Report 是你放了CrystalReportViewer控件的from
lfrm_customer.crt_result.ReportSource = lrpt_customer
'crt_result是你的CrystalReportViewer名稱
lfrm_customer.ShowDialog(Me)