Monday, December 21, 2009

Use colors in a report

In my last post, I talked about the use of colors in a grid. You can use the discussed example to add some spice to your forms.
But the same can be applied to reports as well. Anyone remembers those old dot matrix printers, with that huge stacks of print paper? The paper had green lines, in order to improve the readability.
You can get the same effect, with almost any report in Ax. This is some coding I did a couple of years ago for a user that complained about his report, saying the characters where "all dancing around on the paper".

Create a static method on a class, for example the Global class. (this way you can reuse this code on multiple reports)

static void SetReportLine(ReportSection _ReportSection)
{ int controlcount;
int counter;

int usecolor;
int oldcolor;

object reportobject;





for(counter=1;counter<=controlcount;counter++) { reportobject=_ReportSection.controlNo(counter); reportobject.backgroundColor(usecolor); } }

Now all you have to do, is call this static method from your report. Call it from the executed section in the report, before the call to super, like this

public void executeSection()
{ ;


The result will look something like this:

Eco tip: Again, don't overdo the use of this effect. As all coloring needs to be printed, ink is used. The darker you color your lines, the more ink gets used. So this tip isn't that eco friendly, as it is retro style.


  1. Hey Willy,

    Great tips... this is just what the doctor ordered. Is there any way to avoid applying the background color to the column labels? I like this method, but I only want to apply the color to the actual detail lines, not the headings. The labels are defined in and attached to the report objects, so it seems that we'd have to bash those and use textboxes to insert column headings that are unique/separate from the objects(?) Your thoughts?

  2. Thanks. I am also still looking for a solution to deal with the background colour of the column labels.

  3. Gielie >> did you find a solution to the label color issue?

  4. So far, I solved that by defining the header and the contents sepparatelly (i.e. 2 sections). Not ideal, but hope it helps.

  5. why can't i change the color of the filds that are dirctly refering to table field?