vb.net 如何从vb.net中的文本框传递Crystalreport中文本字段中的值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15153402/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to pass value in textfield in crystalreport from textbox in vb.net
提问by Juan Filipe
I want to have one field in my crystal report in vb.net, I want to display in this textfield is the value of textbox in vb.net form.
我想在 vb.net 的水晶报表中有一个字段,我想在这个文本字段中显示 vb.net 形式的文本框的值。
I made parameters named "prog_user" and set the value of this to the textbox.text but it doesn't display anything.
我创建了名为“prog_user”的参数并将其值设置为 textbox.text 但它不显示任何内容。
heres my code I put it on report_viewer_shown events in vb.net
继承人我的代码我把它放在 vb.net 中的 report_viewer_shown 事件上
Dim crpath, filepath As String
Private Sub rpt_viewer_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
cryrpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
crpath = "D:\LEGAL\NLRC_new_022213\NLRC"
filepath = crpath & "\Legal Records.rpt"
cryrpt.Load(filepath)
cryrpt.RecordSelectionFormula = "{Command.CaseNo} = " & case_no
crviewer.ReportSource = cryrpt
Legal_Records1.SetParameterValue("prog_user", textbox1.text)
crviewer.Refresh()
end sub
what might be the problems if this? the other data in my crystal report display the correct value from the database.
如果这可能是什么问题?我的水晶报告中的其他数据显示了数据库中的正确值。
回答by E-r Gabriel Doronila
try clearing it before adding the values
在添加值之前尝试清除它
With cryrpt
.ParameterFields("prog_user").CurrentValues.Clear()
.ParameterFields("prog_user").CurrentValues.Add(Textbox1.text)
End With
回答by mlieven
Try something like this
尝试这样的事情
cryrpt = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
crpath = "D:\LEGAL\NLRC_new_022213\NLRC"
filepath = crpath & "\Legal Records.rpt"
cryrpt.Load(filepath)
cryrpt.RecordSelectionFormula = "{Command.CaseNo} = " & case_no
cryrpt.ParameterFields("prog_user").CurrentValues.Clear()
cryrpt.ParameterFields("prog_user").CurrentValues.Add(textbox1.text)
crviewer.ReportSource = cryrpt
crviewer.Refresh()
回答by jmvarquez
This will work using textbox info. with CR:
这将使用文本框信息工作。与 CR:
Dim report As New CrystalReport1
Dim objText As CrystalDecisions.CrystalReports.Engine.TextObject = report.ReportDefinition.Sections(1).ReportObjects("Text1")
objText.Text = Me.TextBox1.Text
FrmPrint.CrystalReportViewer1.ReportSource = report
FrmPrint.Show()

