Solved

Decimal Align

Posted on 2003-11-11
9
513 Views
Last Modified: 2012-05-04
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
0
Comment
Question by:RealMrTea
9 Comments
 
LVL 22

Expert Comment

by:_TAD_
ID: 9726880

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.
0
 
LVL 23

Expert Comment

by:naveenkohli
ID: 9727019
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.
0
 

Expert Comment

by:egibson
ID: 9727739
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.
0
Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

 
LVL 6

Expert Comment

by:etmendz
ID: 9728618
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...
0
 
LVL 22

Expert Comment

by:_TAD_
ID: 9728718


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.

0
 
LVL 7

Author Comment

by:RealMrTea
ID: 9732246
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...
0
 
LVL 1

Expert Comment

by:LosBear
ID: 9733120
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

0
 
LVL 7

Accepted Solution

by:
RealMrTea earned 0 total points
ID: 9739642
Thanks all for your comments but I have found a better solution.  Here is what I did just in case anyone wants to know:

Before the report starts, I go through all of the controls with the formats that I am looking for.  i.e. ~ A format with a ")" or a " CR" or a "[RED]" flag.  I add these items to an object that holds a reference to the controls and I also add another control that is a TextBox with a ")" or " CR" in it.

When I am running the report I loop through this collection of controls and either turn the text to a blank or to the apporopriate text.  This way, I do not have to loop through all the controls each time a section is rendored.  This makes it pretty dang fast.

Thanks again...hopefully this will help someone else out.
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A basic question.. “What is the Garbage Collector?” The usual answer given back: “Garbage collector is a background thread run by the CLR for freeing up the memory space used by the objects which are no longer used by the program.” I wondered …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question