RDLC 中分组的替代行颜色

发布于 2024-10-07 04:39:47 字数 179 浏览 0 评论 0原文

我需要在 RDLC 报告中创建备用行颜色,该报告也考虑了组。

如果我使用表达式

=Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White")

显然这会在使用组时产生问题。我没有太多运气找到信息,所以任何帮助都会很棒。

I need to create alternate row colours in my RDLC report which also takes into account groups.

If I use the expression

=Iif(RowNumber(Nothing) Mod 2, "PaleGreen", "White")

Obviously this creates problems when groups are used. I've not had much luck finding information so any help would be great.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱情眠于流年 2024-10-14 04:39:47

决定使用我在网上找到的以下代码:

=IIf(RunningValue(Fields!GroupId.Value, CountDistinct, Nothing) MOD 2, "White", "#d6f1fc")

它不会交替每一行的颜色,而是使该组中的所有行保持相同的颜色,这使得报告美观且易于阅读。

Decided to go with the following code I found online:

=IIf(RunningValue(Fields!GroupId.Value, CountDistinct, Nothing) MOD 2, "White", "#d6f1fc")

It doesnt alternate every row colour but keeps all the rows in that group the same colour which make the report nice and easy to read.

暮年 2024-10-14 04:39:47

我知道这个话题很久以前就被提出过,但如果有人有类似的问题(就像我一样)并遇到这个话题,以下是我解决它的方法。以下是我的报告中的报告分组和示例结果的示例:

组 1
   子 1
   子 2
   子 3

组 2
   子 1
   子 2
   Sub 3

请注意,“Sub [1-3]”是完全相同的标头。使用(Fields!GroupId.Value, CountDistinct, Nothing)时,语句确定只有3个唯一值,当到达重复子组(Sub[1-3])时,RunningValue的结果不增加。

您可以通过在报告中添加额外的列,然后添加表达式来测试这一点:(RunningValue(Fields!GroupId.Value, CountDistinct, Nothing)。结果将如下所示:

Group 1
   子 1   1
   子 2   2
   子 3   3

组 2
   子 1   3
   子 2   3
   Sub 3   3

由于值开始重复,交替行逻辑的“mod 2”部分变得混乱。为了解决这个问题,我让 RunningValue 语句结合了 Group 标头和子组:

(RunningValue(Fields!GroupId.Value+Fields!SubGroupId.Value, CountDistinct, Nothing)

执行此操作后,我得到了以下结果:

Group 1
   子 1   1
   子 2   2
   子 3   3

组 2
   子 1   4
   子 2   5
   Sub 3   6

将其放入交替行表达式中,它应该可以工作!

I know this topic was brought up ages ago, but in case somebody has a similar issue (like I did) and runs into this thread, here is how I tackled it. Here is an example of the report grouping and sample results in my report:

Group 1
   Sub 1
   Sub 2
   Sub 3

Group 2
   Sub 1
   Sub 2
   Sub 3

Notice that 'Sub [1-3]' are the exact same header. When using (Fields!GroupId.Value, CountDistinct, Nothing), the statement determines that there are only 3 unique values, and when it gets to the repeating subgroups (Sub [1-3]), the result of the RunningValue does not increase.

You can test this out by putting an extra column in your report and then the expression: (RunningValue(Fields!GroupId.Value, CountDistinct, Nothing). The results would look like this:

Group 1
   Sub 1   1
   Sub 2   2
   Sub 3   3

Group 2
   Sub 1   3
   Sub 2   3
   Sub 3   3

Because the values start repeating, the 'mod 2' portion of the alternating row logic gets messed up. To work around this I had the RunningValue statement combine the Group header as well as the Sub group:

(RunningValue(Fields!GroupId.Value+Fields!SubGroupId.Value, CountDistinct, Nothing)

After I did this I got this result:

Group 1
   Sub 1   1
   Sub 2   2
   Sub 3   3

Group 2
   Sub 1   4
   Sub 2   5
   Sub 3   6

Throw that in to your alternating row expression and it should work!

夜访吸血鬼 2024-10-14 04:39:47

使用这个:=iif(RowNumber(Nothing) Mod 2 = 0, true,false)

use this: =iif(RowNumber(Nothing) Mod 2 = 0, true,false)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文