Link to home
Start Free TrialLog in
Avatar of RealMrTea
RealMrTea

asked on

Decimal Align

I am trying to add my own functionality into DataDynamics ActiveReports.NET which will allow me to decimal align a column.

Here is an example of why it is important:
-You chose to make a negative number suronded by braces (i.e. ~ -$34.53 = ($34.53)), and you right align the column.  So we have the column.

  $89.43
($34.53)
  $12.97
($11.86)

Financial people want this column aligned on the decimal point.

This I don't think would be to much of a problem if I had some way of determining the width of a character so that I would know how much to move each field by.  Is there a way to get the width of a character in .NET?  I would be whiling to use Managed C++ or any other suggestions people might have.

Thanks in Advance,
Eric
Avatar of _TAD_
_TAD_


A quick method would be to convert all of your report fonts to Courier (New).

All characters in Courrier(New) have the exact same width.  Otherwise each character is different.
Financial charts align the numbers to right. So far I have not come across any body who has asked about decimal alignments. I would rather talk to the clients about it than trying to find a solution which depends a lot on what font you are using.
Decimal Align is a must for this particular application and I can not insure that the characters will always be in Courrier.  There has to be a way.
The Courier font, as mentioned by _TAD_, should help you simplify the solution to your problem.

You might also want to consider the masked edit control. If necessary, you might want to create a custom control based on the MaskedEdit control so you can use it in your reports as well. The MaskedEdit control is an ActiveX control MSMASK32.OCX with a class name MaskEdBox. I am not sure if there is a .Net equivalent, though. But documentation suggests support for ActiveX in .Net.

If you have the MSDN Library installed in your local machine, please read the following article on this subject. ms-help://MS.MSDNQTR.2002APR.1033/masked/html/vbobjMaskEdit.htm

Have fun...


RealMrTea/Egibson,
  What kind of reporting tool are you using?  If this is an ad-hoc report then you can *always* garantee that it will be in courrier.  If it is not an ad-hoc report, then you should really be using a professional reporting tool like Crystal Reports.

Then it comes down to what that reporting tool capable of.

Avatar of RealMrTea

ASKER

Here is the catch, Active Reports happens to be cheaper and we have done much development getting an ad-hoc reporting tool up and running.  Active Reports may support decimal align ment in the future but as of now they do not.  Also, support for custom controls in Active Reports is limited and seems to be kind of buggy.  Crystal is not an option at this time.

If it was just me deciding, I would say that I would wait for Active Reports to get their stuff together but until then, I have to think of a way to solve the problem.

I can not always use Courier because the user can change the fonts and should be able to change the fonts.

Is there just no way to measure a character in a font?  There has to be because Crystal does support this functionality...
I use Active Reports - personally, i like it MUCH better than CR...
I would do what TAD said, make it a font such as courier New since each character uses exactly the same amout of space, THEN
add a space at the end of positive numbers

'THIS ASSUMES YOU ARE USING BOUND DATA
ActiveReport_FetchData()
'Test for Negative
     If x < 0 Then
          'positive numbers
          x = x & " "             'this will add a space after your value
     End If
End Sub

Don't forget to right justify the field/column

i had to do this for a client already once, they understand that if they use a different font, it will move the numbers around, and since Courier New is an accepted Accounting font, they are fine with it.

hope this help
Bear

ASKER CERTIFIED SOLUTION
Avatar of RealMrTea
RealMrTea

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial