Insert a text on your crystal report from code

muhammadanzar

Member
Joined
Dec 25, 2005
Messages
18
Programming Experience
Beginner
hi
how i can set a textvalue in my code and show this text in my report.
Please told me how to do this. which invlove small piece of code:p
i get this code from net and got error on the red areas. the following explations with it
Explanation:
Via a text object: This is my recommended way to go: create a text object in your report, give it a clear name and drag it on your form.
Code:
-----------------------------------------------------------------------------------
Dim SampleReportText As CrystalDecisions.CrystalReports.Engine.TextObject = CType(rpt.ReportDefinition.ReportObjects.Item("PersonalCommentsText"), CrystalDecisions.CrystalReports.Engine.TextObject)
SampleReportText.Text =
Me.txtTextObject.Text
-----------------------------------------------------------------------------------
rpt i think it is an object which can make like this
Dim rpt As CrystalReport1
but how can i remove this error
Me.txtTextObject.Text
Your help in this regard highly appriciated


 
Last edited:
Dim YourRpt As New YourReportName
Dim ReportText1 As CrystalDecisions.CrystalReports.Engine.TextObject
ReportText1 = CType(YourRpt.ReportDefinition.ReportObjects.Item("TextBoxName"), CrystalDecisions.CrystalReports.Engine.TextObject)
ReportText1.Text = "This is the text I want" 'or anyControl.text

The blue text represents text you need to modify to match actual names in your project.
 
Back
Top