vb.net 向RDLC自定义代码添加多个功能
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29537886/
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
Adding multiple functions to RDLC custom code
提问by hira
I am trying to make a comparatively complex rdlc report for my web application and the problem that I am currently facing is that there is one function defined in the custom code section of the report. And then I added another function there and the report is not executing giving an error "The definition of report is invalid." Everytime I remove this function the report runs smoothly, when I add it back it gives this error in the report viewer.
我正在尝试为我的 Web 应用程序制作一个相对复杂的 rdlc 报告,我目前面临的问题是报告的自定义代码部分中定义了一个函数。然后我在那里添加了另一个函数,报告没有执行,并给出错误“报告的定义无效”。每次删除此功能时,报告都会顺利运行,当我将其添加回来时,它会在报告查看器中出现此错误。
回答by Er Mayank
For writing custom code in rdlc :
在 rdlc 中编写自定义代码:
- On the Report menu, click Report Properties.
- On the References tab, click the add button and then select or browse to the assembly from the Add Reference dialog box.
- In Classes, type name of the class and provide an instance name to use within the report. That's in the case of instance members, in the case of static (shared in VB) members, you don't need to add anything in Classes.
- 在“报告”菜单上,单击“报告属性”。
- 在“引用”选项卡上,单击“添加”按钮,然后从“添加引用”对话框中选择或浏览到程序集。
- 在类中,键入类的名称并提供要在报告中使用的实例名称。这是实例成员的情况,对于静态(在 VB 中共享)成员的情况,您不需要在类中添加任何内容。
In Custom Code You can Write your functions:
在自定义代码中,您可以编写函数:
Public ReadOnly Property FetchSomeData() As String
Get
Return sharedMember
End Get
End Property
Dim sharedMember As String = "Shared Data (Does not require initialization)"
Public Function MyFunction(ByVal s As String)
'' Write your code and return String
Return s.toUpper()
End Function

