Question
“How do I change the current display formats provided with ReportBuilder (or add new display formats)?”
Solution
The built-in display formats are defined in the GetDisplayFormats routine of the TppDisplayFormat class inside the ppDisplayFormat.pas file. Descending from this class gives you the opportunity to replace these values as well as customize the way ReportBuilder handles certian display formats.
Once you have created a descendant that provides the needed changes, simply assign the global variable gcDisplayFormat to the new descendant class and the new information will be used.
Download: ReplaceDisplayFormats.zip
Sample Delphi code:
Assign the new descendant class…
uses
  ppUtils;
begin
  gcDisplayFormat := TmyDisplayFormat;
 
  Designer.ShowModal;
end;
– New GetDisplayFormats routine…
class procedure TmyDisplayFormat.GetDisplayFormats(aDataType: TppDataType; aFormatList: TStrings);
begin
  if aFormatList = nil then Exit;
  aFormatList.Clear;
  case aDataType of
  
    dtString:
      begin
        aFormatList.Add('Phone'           + #1 + '!\(999\)\ 000\-0000;0; ');
        aFormatList.Add('Extension'       + #1 + '!99999;0; ');
        aFormatList.Add('Social Security' + #1 + '000\-00\-0000;0; ');
        aFormatList.Add('Short Zip Code'  + #1 + '00000;0; ');
        aFormatList.Add('Long Zip Code'   + #1 + '00000\-9999;0; ');
        aFormatList.Add('Date'            + #1 + '!99/99/00;0; ');
        aFormatList.Add('Long Time'       + #1 + '!90:00:00\ >LL;0; ');
        aFormatList.Add('Short Time'      + #1 + '!90:00;0; ');
      end;
    dtInteger, dtSingle, dtDouble, dtExtended, dtCurrency, dtLongint:
      begin
        aFormatList.Add('-1.234'     + #1 + '#.0;-#.0');
        aFormatList.Add('-1.234,40'  + #1 + '#.0,00;-#.0,00');
        aFormatList.Add('(1.234,40)' + #1 + '#.0,00;(#.0,00)');
        aFormatList.Add('(£1.234,40)'+ #1 + '£#.0,00;(£#.0,00)');
        aFormatList.Add('-£1.234,40' + #1 + '£#.0,00;-£#.0,00');
        aFormatList.Add('-£1.234'    + #1 + '£#.0;-£#.0');
        aFormatList.Add('(£1.234)'   + #1 + '£#.0;(£#.0)');
        aFormatList.Add('($1,234.40)'+ #1 + '$#,0.00;($#,0.00)');
        aFormatList.Add('-$1,234.40' + #1 + '$#,0.00;-$#,0.00');
        aFormatList.Add('-$1,234'    + #1 + '$#,0;-$#,0');
        aFormatList.Add('($1,234)'   + #1 + '$#,0;($#,0)');
        aFormatList.Add('-1234,4 %'  + #1 + '0 %');
        aFormatList.Add('-1234,40 %' + #1 + '0,00 %');
      end;
    dtDate:
      begin
        aFormatList.Add('4.3.01'            + #1 + 'd.m.yy');
        aFormatList.Add('04.03.01'          + #1 + 'dd.mm.yy');
        aFormatList.Add('04.03.2001'        + #1 + 'dd.mm.yyyy');
        aFormatList.Add('4-Mar-01 '         + #1 + 'd-mmm-yy');
        aFormatList.Add('04-Mar-01 '        + #1 + 'dd-mmm-yy');
        aFormatList.Add('4 March, 2001'     + #1 + 'd mmmm, yyyy');
        aFormatList.Add('4.3'               + #1 + 'd.m');
        aFormatList.Add('Mar-01'            + #1 + 'mmm-yy');
        aFormatList.Add('March-01'          + #1 + 'mmmm-yy');
      end;
    dtTime:
      begin
        aFormatList.Add('1:30 PM'    + #1 + 'h:nn AM/PM');
        aFormatList.Add('13:30'      + #1 + 'h:nn');
        aFormatList.Add('1:30:55 PM' + #1 + 'h:nn:ss AM/PM');
        aFormatList.Add('13:30:55'   + #1 + 'h:nn:ss');
      end;
    dtBoolean:
      begin
        aFormatList.Add('Yes'  + #1 + 'Yes;No');
        aFormatList.Add('Y'    + #1 + 'Y;N');
        aFormatList.Add('True' + #1 + 'True;False');
        aFormatList.Add('T'    + #1 + 'T;F');
        aFormatList.Add('OK'   + #1 + 'OK;');
        aFormatList.Add('Done' + #1 + 'Done;');
        aFormatList.Add(''     + #1 + ';Not OK');
        aFormatList.Add(''     + #1 + ';Not Done');
      end;
    dtDateTime:
      begin
        aFormatList.Add('4.3.01 1:30:55 PM' + #1 + 'd.m.yy h:nn:ss AM/PM');
        aFormatList.Add('4.3.01 13:30:55'   + #1 + 'd.m.yy h:nn:ss');
        aFormatList.Add('4.3.01'            + #1 + 'd.m.yy');
        aFormatList.Add('04.03.01'          + #1 + 'dd.mm.yy');
        aFormatList.Add('04.03.2001'        + #1 + 'dd.mm.yyyy');
        aFormatList.Add('4-Mar-01 '         + #1 + 'd-mmm-yy');
        aFormatList.Add('04-Mar-01 '        + #1 + 'dd-mmm-yy');
        aFormatList.Add('4 March, 2001'     + #1 + 'd mmmm, yyyy');
        aFormatList.Add('4.3'               + #1 + 'd.m');
        aFormatList.Add('Mar-01'            + #1 + 'mmm-yy');
        aFormatList.Add('March-01'          + #1 + 'mmmm-yy');
      end;
  end; {case, DataType}
end;