This tip just shows one of the many ways to use styles in your reports. Here, we’ll create a function that determines the background color for a particular area.
If you click on Report – then Report Properties in the menu (assuming you’re in BIDS) and choose the ‘Code’ tab. Now, before we start, it’s best to point out that this is not a normal code surface – pretty much only a textbox, so there’s no intellisense, so you’ll need to know what you’re doing.
Here’s a code sample you can go by:
Function ColorStyle(ByVal Style As String) As String Select Case UCase(Style) Case "HEADER" Return "LightBlue" Case "FOOTER" Return "Blue" Case "SUBTITLE" Return "DarkBlue" End Select End Function
Note that these can easily also be the normal HTML hex numbers you might be used to.
To use this function, you will click on the color property in the property view which you need to use it with, such as the Backtround color of a particular control. Instead of choosing a color from the list, you’d type in something like:
=code.ColorStyle("Header")
Of course, you’ll see the results when the report is actually run.
All Things DotNet Discussed – Winforms/ASP.Net/SharePoint/WPF
Leave a reply
You must be logged in to post a comment.