Can application settings be used as static labels in CR?
I'm using VS 2008 and VB 2008 with the bundled CR.
I want to be able to show data from an application setting string in a text box in the report header.
Is this possible? If so, can it be done in the report itself, or do I have to code it into the parent form?
David Hilton replied
I'm not sure where you got that code from but it isn't right.
- In your For Each loop you are declaring your Field object as a ReportDocument. Your ReportDocument is the actual Crystal Report so you definitely don't want to do that.
- I'm not sure what you are trying to loop through either Me.CrystalDecisions.CrystalReports ?
- You are on the right track in your If statement though
Here is a quick sample. Note this assumes the TextObject is the only, or first item in your object collection. You'll need more robust code to work in your situation.
Dim strNewText As String Dim crTextObject As CrystalDecisions.CrystalReports.Engine.TextObject crReportDocument = New ReportDocument() crReportDocument.Load("C:\path to my report\myreport.rpt") ' change the text of the object strNewText = "New text here" crTextObject = CType(crReportDocument.ReportDefinition.ReportObjects.Item(0), TextObject) ' set the text of the text object on the report. crTextObject.Text = strNewText