vb.net 在VB.net中动态更改Crystal Report的文本对象值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15727339/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 13:03:33  来源:igfitidea点击:

Change Text Object Value of Crystal Report Dynamically in VB.net

vb.netparameterscrystal-reports

提问by Jay Marz

I have this picture of my current format of crystal report. enter image description here

我有这张水晶报告格式的图片。 在此处输入图片说明

My problem is, I want to set the value of fullNamefield dynamically depending on the query result of my vb.net form. For example, I have this code from my vb form,

我的问题是,我想fullName根据我的 vb.net 表单的查询结果动态设置字段的值。例如,我的 vb 表单中有这个代码,

sql = "SELECT fullName FROM tblClient WHERE clientID = '" & ST-TAC-23 & "'"
da = new SqlDataAdapter (sql, con)
dt = new DataTable
da.fill(dt)

I want the dtvalue to be passed on fullNameobject in my crystal report. For example the dtvalue is Mark Zucker, I want the fullNamefield in my cr to display Mark Zucker also. How could possibly do that?

我希望将dt值传递给fullName我的水晶报告中的对象。例如,dt值是 Mark Zucker,我希望fullName我的 cr 中的字段也显示 Mark Zucker。怎么可能这样做?

回答by Jay Marz

I have found out the best trick for this problem. This is how I fixed it.

我已经找到了解决这个问题的最佳技巧。这就是我修复它的方式。

In the loadevent of the form (form for crystal report viewer), I coded this lines,

load表单(用于水晶报表查看器的表单)的情况下,我对此行进行了编码,

Dim fName As TextObject
fName = rptDoc.ReportDefinition.ReportObjects("crFullName")
' display the value for the report
fName.Text = frmAccInventory.lblName.Text

Where "crFullName" is the name of the text objectin crystal report. rptDocis declared at frmAccInventory as new crystalReport1 (name of the crystal report file)

其中“crFullName”是text object水晶报表中的名称。rptDoc在 frmAccInventory 中声明为新的 crystalReport1(水晶报告文件的名称)

credits to Mikaykay of http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/daa7e60d-a444-449d-9ac2-a57415217bbc/

归功于http://social.msdn.microsoft.com/Forums/en-US/vscrystalreports/thread/daa7e60d-a444-449d-9ac2-a57415217bbc/ 的Mikaykay