| Changing the color of the content |
|
In this report we change the color according the purchase frequency.
|
|
Description
|
 |
First of all create a simple report with one frame, a connection and
SQL component |
 |
In this report drag one text control and set its valueExp as
purchfrequency.
|
 |
Then double click the text control and select the method tab.
|
 |
Select the Function
OnRow( row As AcDataRow ) and click Override button, which is used in the previous example.
|
 |
Type the remaining lines to the function after
Super::OnRow( row )
|
|
Select Case
Trim(DataValue)
Case "A"
Font.Color=Red
BackgroundColor=Blue
Case "B"
Font.Color=Cyan
BackgroundColor=Red
Case "C"
Font.Color=Forest
Font.Bold=True
BackgroundColor=Cyan
Border.Pen=SingleLine
Border.Color=Red
Size.Width=Len(DataValue)*200
DataValue=DataValue & "Low Frequency"
End Select
End Sub
End Select
|
 |
The code then changes the color according to its
value
|
|
|
Here A, B, C are the purchase Frequency. If we run this report the color will be change according to the purchase Frequency
In this design, we introduced with a new function Trim.
|
|
As you can see from the syntax, you can give more than one value to compare with Case statement. This is done by separating values by a ‘,’(coma). We can also give a range in case statement. This is done using ‘To’ keyword. The Select Case is ended with ‘End Select’ statement. We even can use a ‘Case Else’ statement, which is done as the default statements. The end of statement block is determined by the occurrence of next Case or End Case.
|
|
Function |
Description |
| LTrim(<string expression>) |
Returns a copy of a string without
leading spaces. |
| RTrim(<string expression>) |
Returns a copy of a string without
trailing spaces. |
| Trim(<string expression>) |
Returns a copy of a string with
neither leading nor
trailing spaces. |
|
|
We trim the data value to remove any leading or trailing spaces. For that purpose we are using the function Trim.
|
|
|