Question:
How can I print a report whose rows’ background colors are interspersed, in a zebra-like pattern?
Solution:
To do so, go to the section’s Format event and insert a script to test the row’s current color. A sample script for this is presented below:
Sub Detail_Format
Dim White, Color, i
Color = Me.Field1.BackColor.Name
White = System.Drawing.Color.White.Name
if Color = "ffffffff" then
Color = "White"
end if
if Color = White then
'Gray
for i = 1 to 2
rpt.Sections.Item("Detail").Controls.Item("Field" & i).BackColor = System.Drawing.Color.Gray
next
else
'White
for i = 1 to 2
rpt.Sections.Item("Detail").Controls.Item("Field" & i).BackColor = System.Drawing.Color.White
next
end if
if Color = "ffffffff" then
Color = "White"
else
Color = "Gray"
End If
End Sub
Attached to this article is a sample application developed with E3 version 6.6.292.
