vb.net 水晶报表 - 在公式中使用当前对象的值

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

Crystal reports - using value of current object in formula

c#vb.netcrystal-reportsself-reference

提问by Miquel Coll

I am creating a Crystal Report using c# and I have to replicate a simple formula in 320 different parameters but always with the same condition as follows:

我正在使用 c# 创建一个水晶报表,我必须在 320 个不同的参数中复制一个简单的公式,但始终具有相同的条件,如下所示:

if ({Precios.AhorroE1}[1] = '-') then crGreen else ( crRed )

Each object has a different name (in the example aboce, Precios.AhorroE1 but I have to make the SAME condition for 320 different objects.

每个对象都有不同的名称(在示例 aboce 中,Precios.AhorroE1 但我必须为 320 个不同的对象设置相同的条件。

I've been trying to find a way to refer to the object that is evaluating the formula but I couldn't find it. I would like to know if it is possible to do something similar to:

我一直试图找到一种方法来引用正在评估公式的对象,但我找不到它。我想知道是否可以做类似的事情:

if ({currentobject}[1] = '-') then crGreen else ( crRed )

Where currentobjectwould be the object evaluating the formula.

currentobject评估公式的对象在哪里。

回答by Ryan

For formulas that evaluate to almost alldata types you can use the keyword CurrentFieldValueto format it. So if you had a formula that evaluated to a string, you could place it in the report and then set the color of its text the way you describe:

对于计算为几乎所有数据类型的公式,您可以使用关键字对其CurrentFieldValue进行格式化。因此,如果您有一个计算为字符串的公式,您可以将它放在报告中,然后按照您描述的方式设置其文本的颜色:

if CurrentFieldValue='-' then crRed else crGreen

if CurrentFieldValue='-' then crRed else crGreen

Except formulas can never evaluate to an array so you can not use it in the way you're describing by indexing into the CurrentFieldValueas if it were one.

除了公式永远不能对数组求值,因此您不能通过将它CurrentFieldValue作为一个索引来描述的方式使用它。