Solved

Decimal Align

Posted on 2003-11-11
9
509 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

760 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now