【问题标题】:alternate background color for tablix in aggregate/sum in SSRSSSRS 中聚合/总和中 tablix 的备用背景颜色
【发布时间】:2012-03-01 06:38:37
【问题描述】:

我必须为报告检索到的行实现备用背景颜色,但问题是它具有聚合/求和功能并且无法正常工作,因此我使用了下面的代码 -

Private bOddRow As Boolean 
'************************************************* ************************ 
' -- Display green-bar type color banding in detail rows 
' -- Call from BackGroundColor property of all detail row textboxes 
' -- Set Toggle True for first item, False for others. 
'************************************************* ************************ 
Function AlternateColor(ByVal OddColor As String, _ 
ByVal EvenColor As String, ByVal Toggle As Boolean) As String 
If Toggle Then bOddRow = Not bOddRow 
If bOddRow Then 
Return OddColor 
Else 
Return EvenColor 
End If 
End Function 
' 
Function RestartColor(ByVal OddColor As String) As String 
bOddRow = True 
Return OddColor 
End Function 

所以我现在有三种不同的单元格背景:

  1. 数据行第一列有 =Code.AlternateColor("AliceBlue", "White", True) (这与上一个答案相同。)
  2. 数据行的其余列有 =Code.AlternateColor("AliceBlue", "White", False) (这也与上一个答案相同。)

我不明白的是,为什么将第一列设为真而将其余列设为假?任何帮助将非常感激。

上面的代码无论有没有下面的功能都相同(我还是不明白)

' 
Function RestartColor(ByVal OddColor As String) As String 
bOddRow = True 
Return OddColor 
End Function 

我从另一个论坛获得此代码,我是 SSRS 和 VB 的新手。请帮忙。

提前致谢

【问题讨论】:

    标签: ssrs-2008 reporting-services reportingservices-2005 ssrs-tablix


    【解决方案1】:

    “Toggle”属性每行只能设置一次:这意味着该函数将切换(切换)它返回的颜色。

    因此,如果您按此顺序调用它们,则此代码将执行以下操作:

    =Code.AlternateColor("AliceBlue", "White", True) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", False) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", False) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", False) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", True) 返回“白色” =Code.AlternateColor("AliceBlue", "White", False) 返回“白色” =Code.AlternateColor("AliceBlue", "White", False) 返回“白色” =Code.AlternateColor("AliceBlue", "White", False) 返回“白色” =Code.AlternateColor("AliceBlue", "White", True) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", True) 返回“白色” =Code.AlternateColor("AliceBlue", "White", True) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", True) 返回“白色” =Code.RestartColor("AliceBlue") 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", False) 返回“AliceBlue” =Code.AlternateColor("AliceBlue", "White", False) 返回“AliceBlue”

    因此,使用 toggle = False 对 AlternateColor 的任何调用都将返回与上次调用相同的颜色。任何带有 toggle = true 的调用都会切换到另一种颜色。

    RestartColor 设置回到起点:也许您总是希望分组的每个实例的顶行都用相同的颜色着色。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-29
      相关资源
      最近更新 更多