Reputation: 11
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
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
Upvotes: 1
Views: 8833
Reputation: 1
Dim objText As CrystalDecisions.CrystalReports.Engine.TextObject =
Report.ReportDefinition.Sections(1).ReportObjects("txtDate")
objText.Text = frmList.txtCall.Text
Upvotes: -1
Reputation: 3070
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!
Upvotes: 4