Dynamically Changing Font Family Based on Conditions in a Report Using Bold Reports' Code Module
Dynamically change the text’s font family based on certain conditions in expressions. This allows you to customize the appearance of your report and improve its readability. Follow these steps to learn how to accomplish this.
Using the Code Module, change the text font family based on a condition in the report. Follow these steps to alter the font family of the text dynamically.
Click on the
codein the Properties section of the report.
Include the following VB code snippet inside the code editor. This code is designed to change the font family based on the value of the lang field.
Public Function getFontType(ByVal lang As String) As String If lang = "english" Then Return "Times New Roman" ElseIf lang = "hindi" Then Return "Calibri" ElseIf lang = "korean" Then Return "Algerian" End If End Function
Locate the option to set the font family for the text.
Set the expression for the font family in the tablix cell, like below.
Replace the existing font family value with an expression that calls the getFontType function, passing the relevant language value as the parameter. For example:
- Apply the changes and preview the report to see the dynamically altered font family based on the condition specified in the code module.
Note: Modify the code snippet as needed to include additional language options and corresponding font family values based on your specific requirements.
By following these steps and using the provided VB code snippet, you can customize the font family of text in your report dynamically, improving its readability and appearance based on specific conditions.