DBxtra Documentation

DBxtra Documentation

How Can We Help?

Report Scripting

You are here:
< All Topics

In DBxtra, you can add scripts to certain events of the report and the report controls, these scripts allow you to modify the content or presentation of the controls as well as to give certain behaviors to them; as DBxtra uses the .NET Framework, it exposes the full .NET Framework in the scripting environment (with correct references and Using/Imports statements), so any function in the .NET Framework can be used there, there is also some DBxtra specific functions that you can use there.

The first thing you must do is to select which scripting language you want to use, in DBxtra you can use C#, VB.NET or JScript.NET, we recommend the use of VB.NET as most of our examples use that language, but we also provide examples in C# if requested, also please be aware that we don’t provide examples in JScript.NET.

To select the scripting language, you need to select the Report in the Property Grid (or click outside the report) and go to Behavior->Script Language and select the one you want to use.

Once you select a scripting language, you can start adding code to your report, DBxtra uses event driven programming for the scripting environment, so to make something useful you must handle the events of the report and its controls.

To handle an event, select the control you want to put an event handler and in the Property Grid go to Behavior->Scripts and select the appropriate event for the behavior you want; most of the time, you’ll want to make changes to the contents or presentation of the controls, so you’ll typically select the Before Print event, although depending of what you want to do you may need to select a different one.

Note: Changes to the content or presentation of the controls can only be done before printing the control, and the Before Print event is the last event before that happens.

In some cases you may want to create functions independently of any event, in that case, you can declare them outside any other method (before or after) and they will be accessible in any event you handle, the same applies to variables (in this case, they’ll be global variables), please be aware that the definition of the method or variable will be language dependent.

You may also want to get the value of a particular column for a calculation or to use it for some conditional behavior, in that case, you can use the following function (be aware that the column name is case sensitive):

 

GetCurrentColumnValue(“ColumnName”)

 

If you use this function in the Detail Band, it will get the current value of the referenced column as a .NET Object, so you may want to cast its return value to the appropriate data type you want to use, for example:

 

Dim ColumnValue As Integer = CInt(GetCurrentColumnValue(“ColumnName”))

 

Also, this function refers to the main data source of the report (Data), if you’re using additional data sources (bound sub reports), and want to get the value of the column in the corresponding band of the additional data source, you need to use the same function using the name of the bound sub report band, for example, assuming the band is named DetailReport, you’ll call the function like this:

 

DetailReport.GetCurrentColumnValue(“ColumnName”)

 

All controls, can be called by their name, to know the name of a particular control, you can select it and in the Property Grid go to Design->Name; you can also change the name of the control there.

Finally, if you want to get a dip of what you can achieve using report scripting, you can review our examples: Place a Total Field in the Detail Band and Calculate With Scripts, also, if there is something specific you want to do, you can always ask our support team for guidance into how better achieve it.

 

Table of Contents