vb.net 在运行时更改 Crystal Report 文本对象文本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14641640/
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
Change Crystal Report Text Object Text at Run time
提问by Lethugs
I'm using a Crystal Report on my project. It's working very well but I just want to make it more flexible. I have text objects with text in them. They are not bound since they are just additional information on my report. How can I make those text objects editable during runtime? Something like on mouse click, so the user can edit it like what I do in design? do I need to add a program in my project? I'm using vb.net 2010
我在我的项目中使用了 Crystal Report。它工作得很好,但我只是想让它更灵活。我有带有文本的文本对象。它们不受约束,因为它们只是我报告中的附加信息。如何在运行时使这些文本对象可编辑?像点击鼠标一样,所以用户可以像我在设计中所做的那样编辑它?我需要在我的项目中添加一个程序吗?我正在使用 vb.net 2010
I use this code to call my report
我使用此代码调用我的报告
Dim sett As New DataSet1
Dim oRpt As New Accountability
Dim obj As CrystalDecisions.CrystalReports.Engine.TextObject
obj = oRpt.ReportDefinition.Sections("Section5").ReportObjects.Item("txtRel")
'Connection code, sql query here
Rpt.SetDataSource(dta)
frmReport.CrystalReportViewer1.ReportSource = oRpt
frmReport.CrystalReportViewer1.RefreshReport()
frmReport.Show()
the text object that I need to edit is not bound. Its created during design time
我需要编辑的文本对象没有绑定。它是在设计时创建的
回答by Dilip Raj Baral
Private Sub Form1_Load(sender as Object, e as EventArgs) Handles MyBase.Load
Dim oRpt As New Accountability
frmReport.CrystalReportViewer1.ReportSource = oRpt
frmReport.Show()
End Sub
Private Sub btnChangeText_Click(sender as Object, e as EventArgs) Handles btnChangeText.Click
Dim oRpt As New Accountability
' Change the text of the TextObject you want to change here
DirectCast(oRpt.ReportDefinition.ReportObjects("Text1"), TextObject).Text = "Your Text"
DirectCast(oRpt.ReportDefinition.ReportObjects("Text2"), TextObject).Text = "Your Second Text"
frmReport.CrystalReportViewer1.ReportSource = oRpt
frmReport.CrystalReportViewer1.RefreshReport()
frmReport.Show()
End Sub
This is what you need!
这就是你所需要的!
回答by Acep Suryanto
Dim objText As CrystalDecisions.CrystalReports.Engine.TextObject =
Report.ReportDefinition.Sections(1).ReportObjects("txtDate")
objText.Text = frmList.txtCall.Text

