Interspersing the background color of a report’s rows.

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:

 

  1. Sub Detail_Format
  2. Dim White, Color, i
  3. Color = Me.Field1.BackColor.Name
  4. White = System.Drawing.Color.White.Name
  5. if Color = "ffffffff" then
  6. Color = "White"
  7. end if
  8. if Color = White then
  9. 'Gray
  10. for i = 1 to 2
  11. rpt.Sections.Item("Detail").Controls.Item("Field" & i).BackColor = System.Drawing.Color.Gray
  12. next
  13. else
  14. 'White
  15. for i = 1 to 2
  16. rpt.Sections.Item("Detail").Controls.Item("Field" & i).BackColor = System.Drawing.Color.White
  17. next
  18. end if
  19. if Color = "ffffffff" then
  20. Color = "White"
  21. else
  22. Color = "Gray"
  23. End If
  24. End Sub
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.

Attachments:

Report_Rows.zip

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *