Domanda

I have the following PrintValue code that prints a line to the report (tbasedxreportlink). It prints two fields on one line in the header, the caption and m. The problem is that m is never aligned straight for multiple lines. It always prints all over the place.

How do I get it to align to the right or even print decimal aligned.

Printed Data

Caption One    4,685.33
Caption 2       4.99
Caption three    74,586.88
Caption 4     58.66

Code

procedure PrintValue(Caption, Value: string);
var
  m: string;
  s: string;
begin
  m := FormatFloat(',0.00 ;(,0.00);0.00 ', StrToFloat(Value));
  s := Format('%-24s %15s', [Caption, m]);
  AReportLink.PrinterPage.PageHeader.LeftTitle.Add(s);
end;

The font used on the report is Segoe UI if it matters.

Thanks

È stato utile?

Soluzione 2

I found no easy way to format the strings to get the desired effect. The main reason for that is the simplicity of using the LeftTitle, CenterTitle or RightTitle 'boxes' - they only allow simple string text to be inserted. Nothing fancy allowed not to mention the True Type Font issue.

In order to solve the problem I added a tPanel to the screen and dropped the all screen fields I needed to show up on the grid print to it. I added a tdxCustomContainerReportLink to link to that panel. I then used a tdxCompositionReportLink to print both the grid and the tdxCustomContainerReportLink (panel) as individual items when the print button was pressed by overwriting the current link code:

procedure TFrmViewAcct.dxBarBtnPrintClick(Sender: TObject);
begin
  dxCmpntPrtrDetail.CurrentLink := dxCmpntPrtrDetailLink2;
  inherited;
end;

Thus it prints the grid info then prints what ever is on the panel. Problem solved and you can see how this solution can be flexible.

Yes I could have easily changed to a True Type font but that is an ugly workaround as far as I am concerned especially where standardized fonts need to be observed.

Altri suggerimenti

The simplest way is using monospace (fixed-width) font, for example, Courier New or Lucida Console

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top