In a section report, green bar printouts can be created by setting alternate shades or background color in the report's detail section in the Format event. The following steps demonstrate how to create a Green Bar report.
- On the design surface, double-click the detail section of the report to create an event handling method for the Detail Format event.
- Add the following code to the handler to alternate background colors.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste JUST ABOVE the Detail Format event. Copy Code Dim color As Boolean Visual Basic.NET code. Paste INSIDE the Detail Format event. Copy Code If color = True Then Me.Detail1.BackColor = System.Drawing.Color.DarkSeaGreen color = False Else Me.Detail1.BackColor = System.Drawing.Color.Transparent color = True End If
C# code. Paste JUST ABOVE the Detail Format event. Copy Code bool color; C# code. Paste INSIDE the Detail Format event. Copy Code if(color) { this.detail.BackColor = System.Drawing.Color.DarkSeaGreen; color = false; } else { this.detail.BackColor = System.Drawing.Color.Transparent; color = true; }
- Add controls like TextBox to the report design surface and preview the report.
The following image shows a Green Bar report alternating between Transparent and Dark Sea Green backgrounds: