1

我在我的项目中使用水晶报表。它工作得很好,但我只是想让它更灵活。我有文本对象,其中包含文本。它们不受约束,因为它们只是我报告中的附加信息。如何使这些文本对象在运行时可编辑?像鼠标点击一样,所以用户可以像我在设计中那样编辑它?我需要在我的项目中添加一个程序吗?我正在使用 vb.net 2010

我使用此代码调用我的报告

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()

我需要编辑的文本对象未绑定。它是在设计时创建的

4

2 回答 2

4
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

这就是你需要的!

于 2013-02-25T16:34:20.473 回答
-1
Dim objText As CrystalDecisions.CrystalReports.Engine.TextObject =  
       Report.ReportDefinition.Sections(1).ReportObjects("txtDate")

objText.Text = frmList.txtCall.Text
于 2014-01-22T09:48:59.270 回答