Align a string on Decimal

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to align a column in DataGrid so the decimal's match up (not
using fixed fonts). Is there anyone who has code for doing this using
StringFormat or something else. Thanks.
 
It comes close but really doesn't align the decimal point for Proportional
Fonts, especially numbers like 34.11 and 45.55.
 
Dennis,
My understanding is numerics in proportional fonts are *always* the same
width, so a 5 is the same width as a 1, allowing number to be aligned in
columns with no effort!

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want. You may want to include a

34.11
45.55

Can you post sample code or email me a picture where it is not working!

Hope this helps
Jay

Dennis said:
It comes close but really doesn't align the decimal point for Proportional
Fonts, especially numbers like 34.11 and 45.55.
 
I'm sorry, I meant non-proportional that don't have fixed spacing for the
characters.

Jay B. Harlow said:
Dennis,
My understanding is numerics in proportional fonts are *always* the same
width, so a 5 is the same width as a 1, allowing number to be aligned in
columns with no effort!

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want. You may want to include a

34.11
45.55

Can you post sample code or email me a picture where it is not working!

Hope this helps
Jay

Dennis said:
It comes close but really doesn't align the decimal point for Proportional
Fonts, especially numbers like 34.11 and 45.55.
 
Dennis,
Numerics (0 to 9) in both proportional & non-proportional fonts are always
the same width! (within the same font of course)

My understanding is the reason that numerics are the same widths is so the
digits line up nicely.

So using HorizontalAlignment.right as Ken suggests should be exactly what
you want!! You may want to include set the Format property of the
DataGridTextBoxColumn so that all cells have the same number of decimal
places...

Again can you post sample code or email me a picture where it is not
working!

Hope this helps
Jay
 
You know, I never realized that this was the case and I work with Word and
Excel all the time. I just tried Times New Roman in Word with a right Aligh
tab and you are certainly correct..you've simplified mylife. Thanks a lot.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top